Successive convex approximation ralways return NaN


#1

I’ve got some trouble when using cvxquad to solve the SCA problem which include rel_entr arguments, which runs with results:
failed
optival: NaN
here is my code

cvx_begin
    variable u_optimal(N+1,2);
    variable L;
    expression Rkup(K,N);
    expression Rklow(K,N);
    expression Qk(K,N);
    for k=1:K
        for n=1:N
            W(n,:)=u(n,:)-Vk(k,:);
            Qk(k,n)=h^2+norm(W(n,:))^2-2*W(n,:)*u(n,:)'+2*u_optimal(n,:)*W(n,:)';
            Rkup(k,n)=(rel_entr(Qk(k,n)+rou,Qk(k,n)) + rel_entr(Qk(k,n),Qk(k,n)+rou))/rou;
            Bk(k,n)=(B*rou)/(log(2)*(h*h+norm(W(n,:))^2)*(rou+ h*h+norm(W(n,:))^2));
            Rklow(k,n)=B*log(1+(rou/(h^2+norm(W(n,:))^2)))/log(2)-Bk(k,n)*((u_optimal(n,:)-Vk(k,:))*(u_optimal(n,:)-Vk(k,:))'-norm(W(n,:))^2);
        end
    end
    maximize L;
    subject to
        
       0<=u_optimal(2:N,:)<=1000;
       0<=u_optimal(1,:)<=1;
       999<=u_optimal(N+1,:)<=1000;
       for o=2:(N+1)
           norm(u_optimal(o,:)-u_optimal(o-1,:))<=Vmax;%%%constraint 3
       end
       for kk=1:K
            for j=1:N
                sum(Ck*Tk(kk,j:N).*Rkup(kk,j:N))<=(N-j)*Fk+1000; %%constraint 8
            end
       end
       sum((sum(Tk.*Rklow)))>=L;%%constraint 15
       L>=0;%%P3.1
cvx_end

I don’t really understand the problem I have encountered, are there someone knowing the possible problems!
thanks ahead!


(Mark L. Stone) #2

If you are not using CVXQUAD, please do so by following the directions at CVXQUAD: How to use CVXQUAD's Pade Approximant instead of CVX's unreliable Successive Approximation for GP mode, log, exp, entr, rel_entr, kl_div, log_det, det_rootn, exponential cone. CVXQUAD's Quantum (Matrix) Entropy & Matrix Log related functions .

If you are already uising CVXQUAD, please show the solver and CVX output.


#3

thank you for replying , you see my cvx expressions above, the ‘u_optimal’ and ‘L’ are variables ,and all the cvx_expression have been reformulated as the cvxquad rules, I have checked again and again, could you see some anti-rules in my code ,if so please point out, here is my output via using CVXQUAD, the solver is mosek

Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
=====================================
Using Pade approximation for exponential
cone with parameters m=3, k=3
=====================================
 
Calling Mosek 8.0.0.60: 35064 variables, 13311 equality constraints
   For improved efficiency, Mosek is solving the dual problem.
------------------------------------------------------------

MOSEK Version 8.0.0.60 (Build date: 2017-3-1 13:09:33)
Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (416) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (417) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (777) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (778) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (9602) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (9620) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (16082) of matrix 'A'.
MOSEK warning 710: #1 (nearly) zero elements are specified in sparse col '' (16100) of matrix 'A'.
MOSEK warning 57: A large value of 3.7e+011 has been specified in cx for variable '' (2362).
MOSEK warning 57: A large value of 3.7e+011 has been specified in cx for variable '' (2363).
MOSEK warning 57: A large value of 3.7e+011 has been specified in cx for variable '' (2364).
MOSEK warning 57: A large value of 3.7e+011 has been specified in cx for variable '' (2365).
MOSEK warning 57: A large value of 3.6e+011 has been specified in cx for variable '' (2366).
MOSEK warning 57: A large value of 3.6e+011 has been specified in cx for variable '' (2367).
MOSEK warning 57: A large value of 3.6e+011 has been specified in cx for variable '' (2368).
MOSEK warning 57: A large value of 3.6e+011 has been specified in cx for variable '' (2369).
MOSEK warning 57: A large value of 3.5e+011 has been specified in cx for variable '' (2370).
MOSEK warning 57: A large value of 3.5e+011 has been specified in cx for variable '' (2371).
Warning number 57 is disabled.
Problem
  Name                   :                 
  Objective sense        : min             
  Type                   : CONIC (conic optimization problem)
  Constraints            : 13311           
  Cones                  : 9900            
  Scalar variables       : 35064           
  Matrix variables       : 0               
  Integer variables      : 0               

Optimizer started.
Conic interior-point optimizer started.
Presolve started.
Linear dependency checker started.
Linear dependency checker terminated.
Eliminator started.
Freed constraints in eliminator : 670
Eliminator terminated.
Eliminator started.
Freed constraints in eliminator : 4
Eliminator terminated.
Eliminator - tries                  : 2                 time                   : 0.00            
Lin. dep.  - tries                  : 1                 time                   : 0.00            
Lin. dep.  - number                 : 0               
Presolve terminated. Time: 0.09    
Optimizer  - threads                : 2               
Optimizer  - solved problem         : the primal      
Optimizer  - Constraints            : 8259
Optimizer  - Cones                  : 9901
Optimizer  - Scalar variables       : 32748             conic                  : 31945           
Optimizer  - Semi-definite variables: 0                 scalarized             : 0               
Factor     - setup time             : 0.08              dense det. time        : 0.00            
Factor     - ML order time          : 0.02              GP order time          : 0.00            
Factor     - nonzeros before factor : 7.32e+004         after factor           : 1.13e+005       
Factor     - dense dim.             : 2                 flops                  : 1.35e+007       
ITE PFEAS    DFEAS    GFEAS    PRSTATUS   POBJ              DOBJ              MU       TIME  
0   7.3e+000 1.8e+010 2.5e+010 0.00e+000  4.199544189e+017  0.000000000e+000  1.0e+000 0.20  
1   6.1e+000 1.5e+010 1.9e+010 -1.00e+000 4.199544562e+017  7.558538259e+002  8.4e-001 0.25  
2   5.7e+000 1.4e+010 1.7e+010 -1.00e+000 4.199544476e+017  1.155499455e+003  7.8e-001 0.28  
3   4.4e+000 1.1e+010 1.2e+010 -1.00e+000 4.199544516e+017  2.600606834e+003  6.1e-001 0.31  
4   2.2e+000 5.6e+009 4.3e+009 -1.00e+000 4.199543664e+017  8.972457370e+003  3.1e-001 0.34  
5   8.1e-001 2.0e+009 9.3e+008 -1.00e+000 4.199543335e+017  3.073258466e+004  1.1e-001 0.38  
6   4.9e-002 1.2e+008 1.4e+007 -1.00e+000 4.199534391e+017  4.871188195e+005  6.8e-003 0.42  
7   1.3e-003 3.3e+006 6.3e+004 -1.00e+000 4.199180103e+017  1.602754601e+006  1.8e-004 0.45  
8   5.1e-004 1.3e+006 1.5e+004 -1.00e+000 4.198018811e+017  1.441853666e+006  7.0e-005 0.48  
9   3.2e-004 8.0e+005 7.4e+003 -9.98e-001 4.189638032e+017  1.345511534e+006  4.4e-005 0.52  
10  1.1e-004 2.6e+005 1.4e+003 -9.92e-001 4.143947460e+017  1.367858996e+006  1.5e-005 0.55  
11  2.8e-005 6.9e+004 2.0e+002 -9.65e-001 3.931914442e+017  2.170450927e+006  3.8e-006 0.63  
12  7.4e-006 1.8e+004 3.2e+001 -8.56e-001 3.270944356e+017  4.860727898e+006  1.0e-006 0.72  
13  9.8e-007 2.4e+003 3.0e+000 -5.37e-001 1.293932519e+017  1.312035851e+007  1.3e-007 0.81  
14  4.4e-007 1.5e+002 4.3e-001 3.96e-001  1.137170971e+016  1.802143330e+007  8.5e-009 0.91  
15  1.2e-007 4.3e+001 2.4e-001 9.58e-001  3.202552082e+015  1.769267153e+007  2.4e-009 1.00  
16  2.2e-008 7.9e+000 1.1e-001 1.00e+000  5.866941517e+014  1.712695071e+007  4.4e-010 1.11  
17  4.8e-009 1.7e+000 5.2e-002 1.02e+000  1.264161727e+014  1.509418281e+007  9.5e-011 1.20  
18  1.6e-009 5.6e-001 3.3e-002 1.03e+000  4.055829428e+013  1.126988505e+007  3.1e-011 1.28  
19  1.4e-010 4.9e-002 1.2e-002 1.03e+000  3.481425296e+012  9.185505810e+006  2.7e-012 1.39  
20  1.1e-010 2.5e-002 8.3e-003 1.01e+000  1.765293872e+012  9.158225184e+006  1.4e-012 1.48  
21  1.0e-010 2.4e-002 8.2e-003 1.00e+000  1.711738793e+012  9.163490320e+006  1.3e-012 1.59  
22  1.0e-010 2.4e-002 8.2e-003 1.00e+000  1.711738793e+012  9.163490320e+006  1.3e-012 1.73  
Interior-point optimizer terminated. Time: 1.86. 

Optimizer terminated. Time: 1.88    

Interior-point solution summary
  Problem status  : UNKNOWN
  Solution status : UNKNOWN
  Primal.  obj: 1.7117387934e+012   nrm: 1e+009   Viol.  con: 5e+003   var: 2e+000   cones: 8e-006 
  Dual.    obj: 9.1634903204e+006   nrm: 3e+014   Viol.  con: 0e+000   var: 3e+008   cones: 0e+000 
Optimizer summary
  Optimizer                 -                        time: 1.88    
    Interior-point          - iterations : 23        time: 1.86    
      Basis identification  -                        time: 0.00    
        Primal              - iterations : 0         time: 0.00    
        Dual                - iterations : 0         time: 0.00    
        Clean primal        - iterations : 0         time: 0.00    
        Clean dual          - iterations : 0         time: 0.00    
    Simplex                 -                        time: 0.00    
      Primal simplex        - iterations : 0         time: 0.00    
      Dual simplex          - iterations : 0         time: 0.00    
    Mixed integer           - relaxations: 0         time: 0.00    

------------------------------------------------------------
Status: Failed
Optimal value (cvx_optval): NaN

I don’t know whether the warnings are troublesome for my ultimate results, even so, i was confused by the matrix “A” and variable “” mentioned in the warning sentence and could you please give some advice about how to avoid the warnning .thanks again!


(Erling D.Andersen) #4

Mosek does not solve your problem.

The problem that is inputted is crazy in a numerical senses.

Mosek v9.beta supports the exponential cone (without the approximation stuff) and using that directly is likely to work better. Unfortunately CVX does not use this feature yet.

PS. I do not if it is possible but using the latest Mosek version 8.1 instead of 8.0.0.60 in CVX is a good idea.


#5

I have tried to replace the mosek8.0 with 8.1, but encountered a mistake about the licnese as follows;
when I run the command : mosekdiag

mosekopt: C:\Program Files\Mosek\8\toolbox\r2014a\mosekopt.mexw64
Found MOSEK version : major(8), minor(1), revision(77)
mosekopt returned an error: 1008. [MSK_RES_ERR_MISSING_LICENSE_FILE]
Remember to restart MATLAB if you installed a new license file.
Debug output:
Mosek: Open
Mosek: Using matlab (1) or system calloc (0) ? 0
Mosek: Echo intro

MOSEK Version 8.1.0.77 (Build date: 2019-2-25 13:24:09)
Copyright (c) MOSEK ApS, Denmark. WWW: mosek.com
Platform: Windows/64-X86

FlexLM
 Version                  : 11.14
 Hostname                 : DESKTOP-09J235T
 Host ID                  : "025041000001 16dfbfd0530d 26dfbfd0530d 56dfbfd0530d 988389272b76 74dfbfd0530d 74dfbfd07cc5"
 License path             : C:\Users\samsung\mosek\mosek.lic

Operating system variables
 PATH                     :
Mosek: Check version
Mosek: done
MOSEK Fusion is working correctly.

the mosek 8.1 is installed out of cvx and then configure the path with addpath and javaaddpath,
when I run the command : cvx_setup ,it shows:

Setting CVX paths...already set!
Searching for solvers...5 shims found.
3 solvers initialized (* = default):
 *  Mosek     8.0.0.60    {cvx}\mosek\w64
    SDPT3     4.0         {cvx}\sdpt3
    SeDuMi    1.34        {cvx}\sedumi
4 solvers skipped:
    GLPK                  
        Could not find a GLPK installation.
    Gurobi    unknown     {cvx}\gurobi\w64
        A valid CVX Professional license key was found, but not a
        Gurobi license key. *Both* keys are needed to use Gurobi.
    Mosek_2   8.1.0.77    C:\Program Files\Mosek\8\toolbox\r2014a
        This CVX Professional license does not include MOSEK.
    Mosek_3   8.1.0.77    C:\Program Files\Mosek\8\toolbox\r2014a
        This CVX Professional license does not include MOSEK.
Saving updated preferences...done.
Testing with a simple model...done!
---------------------------------------------------------------------------
To change the default solver, type "cvx_solver <solver_name>".
To save this change for future sessions, type "cvx_save_prefs".
Please consult the users' guide for more information.

I don’t really know why, could you please give a way! thanks!


(Mark L. Stone) #6

your output shows that CVXQUAD was invoked and CVX’s Successive Approximation method was not used. As @Erling pointed out, your model is not good numerically. Because you have not provided the input data, your problem is not reproducible, and readers are not able to provide detailed guidance on how to improve it. nevertheless, you should look for coefficients in your model which are many orders of magnitude from 1, and try to reformulate, for instance by re-scaling, to make these number either exactly zero, or much closer to 1 in magnitude. There might be an extra complication because CVXQUAD is generating new 2 by 2 LMI constraints to replace exponential cone items, and CVX sends these to the solver as Second Order Cone constraints.

As for getting CVX to use Mosek 8,1.0.77, try renaming the cvx/mosek directory to something else so that CVX does not find it. Then, presuming that your mosek license is indeed adequate for mosek 8.1,that may get CVX to use your 8.1 installation rather than the 8.0.0.60 installation in cvx/mosek .