Which toolbox can solve my optimization problem

336 views
Skip to first unread message

Wanming Hao

unread,
Nov 15, 2016, 12:46:59 AM11/15/16
to YALMIP
Hi, every one. 
   Now, I need to solve an optimzation problem as follows: In fact, My problem is to allocate power for maximizing sum rate 

Variables:  X=[x1,x2,...,xn], Y=[y1,y2,...,yn] and Z=[z1,z2,..,zn];  %%Power
maximize:  log(1+a1*x1)+log(1+a2*x2)+...+log(1+an*xn)+log(1+b1*y1)+log(1+b2*y2)+...+log(1+bn*yn)+log(1+c1*z1)+log(1+c2*z2)+...+log(1+cn*zn) %% sum rate
There are 4 constraint conditions: (A C B0 B1 Z0 Z1 are constants)
1. log(1+a1*x)>=A  x=x1, x2,..,xn;
2. sum(X)+sum(Y)+sum(Z)<=C;
3. B0<=log(1+b1*y1)+log(1+b2*y2)+...+log(1+bn*yn)<=B1
4. Z0<=log(1+c1*z1)+log(1+c2*z2)+...+log(1+cn*zn)<=Z1
In fact, the above optimization problem should be convex optimization problem, But when use the CVX toolbox, since the constraint 3, 4 include "Concave<=constant" form, this form is invalid constraint (Disciplined convex programming error:) in CVX toolbex.
Therefore, hope you can help me how to solve it. Thanks a lot in advance.

Johan Löfberg

unread,
Nov 15, 2016, 1:46:22 AM11/15/16
to YALMIP
log() <= is not a convex constraint

If you use YALMIP, any nonlinear solver will be applicable

Wanming Hao

unread,
Nov 15, 2016, 6:48:00 AM11/15/16
to YALMIP
Dear Johan
    Thank you very much for your help. I try to let YALMIP using a nonliner slover "'fmincon'" to solve my problem. But there is one error "Undefined function or method 'ge' for input arguments of type'logdet'" Namely, the constraint codition can not including "log" form, so if the problem can be solved by YALMIP? In addition, it seems impossible to transform the "log" form to other form.
Thanks a lot!

Johan Löfberg

unread,
Nov 15, 2016, 6:51:32 AM11/15/16
to YALMIP
logdet is a very specialized operator which only is used to define logdet objectives when you intend to solve the problem using a logdet aware SDP solver.

Your model above shows no use of log(det)) so I don't even see why you are talking about it

Of course you can have log in constraints

Wanming Hao

unread,
Nov 15, 2016, 6:57:24 AM11/15/16
to YALMIP
Dear Johan
Thank you very much for your help. Yes, my model only includes log, I will try it again. 

Wanming Hao

unread,
Nov 15, 2016, 8:09:08 AM11/15/16
to YALMIP
Dear Johan
    I try to write matlab code as follows. In my computer, it always make error, the reason is that "log" can not be used. Can you help me to analyze the reason?
Thanks a lot.




clear all
clc 
MacroUserSINR=[2 3 4 5 6];
MicroBsHeadSINR{1}=[4 5];
MicroBsHeadSINR{2}=[3 6];
MacroCellUserRateMin=1;
MicroCellUserNumber=4;
sdpvar MacroBsPowerVect(5,1) MicroBsHeadVect(2,2)
ObjMacro=0;
for i=1:5
   ObjMacro=ObjMacro+log(1+MacroBsPowerVect(i)*MacroUserSINR(i));
end
ObjMicro=0;
for m=1:2
    for i=1:2
        ObjMicro=ObjMicro+log(1+MicroBsHeadVect(m,i)*MicroBsHeadSINR{m}(i));
    end
end
Sum=ObjMacro+ObjMicro;   %%%%%%%%%%% Objective function
%%%%%%%%%%%%%%%%% the following are constraints
F=[];
for i=1:5
    F=[F,MacroBsPowerVect(i,1)>=(exp(MacroCellUserRateMin)-1)/MacroUserSINR(i)];  %%%constraints condition LP
end
F=[F,sum(MacroBsPowerVect)+sum(sum(MicroBsHeadVect))<=MacroBsPower];  %%%%% sum power constraint LP
for m=1:2
    MicroBsSumRate=0;
    for i=1:2
        MicroBsSumRate=MicroBsSumRate+log(1+MicroBsHeadVect(m,i)*MicroBsHeadSINR{m}(i));   %%%%%% constrainst condition NLP 
    end
    F=[F,MicroBsSumRate>=MicroCellUserRateMin*MicroCellUserNumber];   %%%%%%% namely A>=sum(log)>=B
    F=[F,MicroBsSumRate<=ClusterMaxRate(m)];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
 ops=sdpsettings('solver','fmincon','verbose',0)
 sol = solvesdp(F,-Sum,ops)

Johan Löfberg

unread,
Nov 15, 2016, 8:10:26 AM11/15/16
to YALMIP
Undefined function or variable 'MacroBsPower'.
 
>> 

Wanming Hao

unread,
Nov 15, 2016, 8:15:38 AM11/15/16
to YALMIP
Sorry, I forgot it, it is 20; MacroBsPower=20

Johan Löfberg

unread,
Nov 15, 2016, 8:18:29 AM11/15/16
to YALMIP
Undefined function or variable 'MicroCellUserRateMin'.
 
>> 

Wanming Hao

unread,
Nov 15, 2016, 8:24:16 AM11/15/16
to YALMIP
Dear John
    Since I only cut one part of my code to run convenience for you. Maybe there are some undifiend paramneters, hope you can understand. MicroCellUserRateMin=1. Ther is another parameters ClusterMaxRate=[20,21]
Thank you very much again. 
Best wishes

Johan Löfberg

unread,
Nov 15, 2016, 8:27:19 AM11/15/16
to YALMIP
Runs without problems

>> ops=sdpsettings('solver','fmincon','verbose',1);
>> sol = solvesdp(F,-Sum,ops)
Your initial point x0 is not between bounds lb and ub; FMINCON
shifted x0 to strictly satisfy the bounds.

                                            First-order      Norm of
 Iter F-count            f(x)  Feasibility   optimality         step
    0       1   -9.380075e+00    4.000e+00    7.988e+00
    1       2   -1.514067e+01    1.765e+00    2.658e+00    1.365e+00
    2       3   -1.629282e+01    1.514e+00    2.117e+00    5.971e-01
    3       4   -1.924883e+01    9.127e-01    2.124e+00    2.492e+00
    4       5   -1.972554e+01    4.455e-01    1.399e+00    8.419e-01
    5       6   -2.020518e+01    0.000e+00    8.268e-01    8.131e-01
    6       7   -2.046445e+01    0.000e+00    2.734e-01    8.060e-01
    7       8   -2.057733e+01    0.000e+00    1.521e-01    9.151e-01
    8       9   -2.058359e+01    0.000e+00    9.992e-02    1.255e-01
    9      10   -2.063533e+01    0.000e+00    3.148e-02    1.156e-01
   10      11   -2.065082e+01    0.000e+00    1.985e-02    1.603e-01
   11      12   -2.065162e+01    0.000e+00    2.000e-02    5.867e-02
   12      13   -2.066613e+01    0.000e+00    5.021e-03    5.118e-02
   13      14   -2.066702e+01    0.000e+00    4.394e-03    1.771e-02
   14      15   -2.066716e+01    0.000e+00    4.000e-03    2.735e-02
   15      16   -2.067032e+01    0.000e+00    2.343e-03    1.828e-02
   16      17   -2.067036e+01    0.000e+00    1.759e-03    2.107e-03
   17      18   -2.067036e+01    0.000e+00    9.617e-04    4.281e-03
   18      19   -2.067036e+01    0.000e+00    8.000e-04    3.017e-03
   19      20   -2.067100e+01    0.000e+00    2.371e-04    4.489e-03
   20      21   -2.067101e+01    0.000e+00    1.600e-04    1.841e-03
   21      22   -2.067116e+01    0.000e+00    2.608e-05    8.202e-04
   22      23   -2.067116e+01    0.000e+00    1.930e-05    6.485e-05
   23      24   -2.067116e+01    0.000e+00    8.891e-06    1.191e-04
   24      25   -2.067116e+01    0.000e+00    4.227e-06    5.725e-05
   25      26   -2.067116e+01    0.000e+00    1.600e-06    3.664e-05
   26      27   -2.067117e+01    0.000e+00    3.200e-07    6.920e-06

Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the selected value of the optimality tolerance,
and constraints are satisfied to within the selected value of the constraint tolerance.

<stopping criteria details>


sol = 

  struct with fields:

    yalmiptime: 0.4939
    solvertime: 0.3641
          info: 'Successfully solved (FMINCON)'
       problem: 0 


Wanming Hao

unread,
Nov 15, 2016, 8:39:45 AM11/15/16
to YALMIP
Dear John 
    Thank you very much. In my computer, it always appears the following error: Certainly, I have install the newest YALMIP  Matlab version is 7.8. 

??? Error: File: slog.m Line: 67 Column: 12
Expression or statement is incorrect--possibly
unbalanced (, {, or [.

Error in ==> sdpvar.log>check_for_special_cases at 82
    f = slog(x-1);

Error in ==> sdpvar.log at 11
        varargout{1} =
        check_for_special_cases(varargin{:});

Error in ==> Untitled at 12
   ObjMacro=ObjMacro+log(1+MacroBsPowerVect(i)*MacroUserSINR(i)); 

Johan Löfberg

unread,
Nov 15, 2016, 8:42:20 AM11/15/16
to YALMIP
Are you using the most recent version of YALMIP, and are you using a modern version of MATLAB?

Wanming Hao

unread,
Nov 15, 2016, 8:44:51 AM11/15/16
to YALMIP
I use the newest version of YALMIP and my version of MATLAB is R2009a (7.8.0)

Wanming Hao

unread,
Nov 15, 2016, 8:46:33 AM11/15/16
to YALMIP
anyway, "sdpt3" can be used in my computer, I use it for other problem.

Johan Löfberg

unread,
Nov 15, 2016, 8:47:35 AM11/15/16
to YALMIP
I guess that old version doesn't support unused output arguments. Hence you have to fix slog.m and explicitly use output names

[unused,common] =

there might be several places where yalmip crashes for the same reason

Wanming Hao

unread,
Nov 15, 2016, 8:55:36 AM11/15/16
to YALMIP
I do it according to your advice, modified as "function [unused,common]= slog(varargin)"   But, it still does not work. and the problem is following;
 for i = 1:length(g)
         gi = extsubsref(g,i);       
         [~,common] = find(mt(getvariables(gi),:) < 0);  %%%%% It reminders that  this line has problem
         y = recover(common(1));
         x = gi*y;
         if length(g)==1
             % Testing some display issues
             f =slogfrac([x;y]);
         else
            f = [f;slogfrac([x;y])];
         end

Johan Löfberg

unread,
Nov 15, 2016, 8:55:42 AM11/15/16
to YALMIP
why are you talking about sdpt3?

Johan Löfberg

unread,
Nov 15, 2016, 8:57:18 AM11/15/16
to YALMIP
?? 

I just told you have to fix that line

Wanming Hao

unread,
Nov 15, 2016, 9:06:03 AM11/15/16
to YALMIP
Dear John
    Thank you very much for your help. I talked about "sdpt3" in order to say the "YALMIP" can work.  Anywhere, it can work, but the solve can not be found: It reminders follows:   I use the same test code I sent you.
sol = 

    yalmiptime: NaN
    solvertime: NaN
          info: [1x196 char]
       problem: 9

Johan Löfberg

unread,
Nov 15, 2016, 9:11:49 AM11/15/16
to YALMIP
Turn on the debug option

Wanming Hao

unread,
Nov 15, 2016, 9:14:52 AM11/15/16
to YALMIP
Yes, the results is:
ops = 

                   solver: 'fmincon'
                  verbose: 1
                    debug: 0
                    usex0: 0
                  warning: 1
             cachesolvers: 0
             showprogress: 0
                saveduals: 1
         removeequalities: 0
         savesolveroutput: 0
          savesolverinput: 0
          saveyalmipmodel: 0
        convertconvexquad: 1
    assertgpnonnegativity: 1
             thisisnotagp: 0
                   radius: Inf
                    relax: 0
                  dualize: 0
                savedebug: 0
                   expand: 1
                allowmilp: 1
           allownonconvex: 1
                    shift: 0
                   dimacs: 0
            beeponproblem: [-5 -4 -3 -2 -1]
                bisection: [1x1 struct]
                  bilevel: [1x1 struct]
                   bmibnb: [1x1 struct]
                      bnb: [1x1 struct]
                   cutsdp: [1x1 struct]
                      kkt: [1x1 struct]
                   moment: [1x1 struct]
                       mp: [1x1 struct]
                    mpcvx: [1x1 struct]
                     plot: [1x1 struct]
                   robust: [1x1 struct]
                      sos: [1x1 struct]
                    baron: []
                 bintprog: [1x1 struct]
                   bonmin: []
                     cdcs: [1x1 struct]
                      cdd: [1x1 struct]
                      cbc: [1x1 struct]
                      clp: [1x1 struct]
                    cplex: [1x1 struct]
                     csdp: [1x1 struct]
                     dsdp: [1x1 struct]
                     ecos: []
                 filtersd: [1x1 struct]
                  fmincon: [1x1 struct]
               fminsearch: [1x1 struct]
                    frlib: [1x1 struct]
                     glpk: [1x1 struct]
                   gurobi: [1x1 struct]
                    ipopt: [1x1 struct]
               intlinprog: []
                   knitro: [1x1 struct]
                  linprog: [1x1 struct]
                   lmilab: [1x1 struct]
                  lmirank: [1x1 struct]
                logdetppa: [1x1 struct]
                  lpsolve: [1x1 struct]
                lsqnonneg: [1x1 struct]
                   lsqlin: [1x1 struct]
                     kypd: [1x1 struct]
                      nag: [1x1 struct]
                    mosek: [1x1 struct]
                    nomad: []
                     ooqp: []
                   penbmi: [1x1 struct]
                   penlab: []
                   pensdp: [1x1 struct]
                      pop: [1x1 struct]
                  qpoases: []
                    qsopt: [1x1 struct]
                 quadprog: [1x1 struct]
               quadprogbb: [1x1 struct]
                     scip: []
                      scs: [1x1 struct]
                     sdpa: [1x1 struct]
                    sdplr: [1x1 struct]
                    sdpt3: [1x1 struct]
                   sdpnal: [1x1 struct]
                   sedumi: [1x1 struct]
                sparsepop: [1x1 struct]
               sparsecolo: [1x1 struct]
                     vsdp: [1x1 struct]
                   xpress: []

Johan Löfberg

unread,
Nov 15, 2016, 9:18:58 AM11/15/16
to YALMIP
Yes what? You've not turned on debug

Wanming Hao

unread,
Nov 15, 2016, 9:24:34 AM11/15/16
to YALMIP
Sorry, how to turn on debug?

Johan Löfberg

unread,
Nov 15, 2016, 9:25:32 AM11/15/16
to YALMIP
ops = sdpsettings('debug',1)

Wanming Hao

unread,
Nov 15, 2016, 9:27:24 AM11/15/16
to YALMIP
It appers the follows:

??? Error: File: apply_recursive_differentiation.m Line: 43 Column: 7
Expression or statement is incorrect--possibly unbalanced (, {, or [.

Error in ==> fmincon_fun at 78
    dx =
    apply_recursive_differentiation(model,xevaled,requested,model.frecursivederivativeprecompute);
    
Error in ==> fmincon at 528
      [initVals.f,initVals.g(:)] = feval(funfcn{3},X,varargin{:});

Error in ==> callfmincon at 58
[xout,fmin,flag,output,lambda] =
fmincon('fmincon_fun',model.x0,model.A,model.b,model.Aeq,model.beq,model.lb,model.ub,callback_con,model.options.fmincon,model);

Error in ==> solvesdp at 350
    eval(['output = ' solver.call '(interfacedata);']);

Error in ==> Untitled at 40
 sol = solvesdp(F,-Sum,ops)
Caused by:
    Failure in initial user-supplied objective function evaluation. FMINCON cannot continue.

Johan Löfberg

unread,
Nov 15, 2016, 9:29:27 AM11/15/16
to YALMIP
The error message looks exactly the same, so the solution is most likely precisely the same

Wanming Hao

unread,
Nov 15, 2016, 9:33:37 AM11/15/16
to YALMIP
Your mean that some original codes need to be modified? How to slove it?
Thanks a lot again

Johan Löfberg

unread,
Nov 15, 2016, 9:34:50 AM11/15/16
to YALMIP

The error is here

??? Error: File: apply_recursive_differentiation.m Line: 43 Column: 7
Expression or statement is incorrect--possibly unbalanced (, {, or [.

and the reason is once again the use of a ~ as output argument in a function call, which isn't supported on your version of matlab, and hence has to be changed

Wanming Hao

unread,
Nov 15, 2016, 9:40:01 AM11/15/16
to YALMIP
Dear John
    Thank you very much for your help. I do it according to your advice and it can work sucessfully. Thanks a lot again again!!
best wishes

Mark L. Stone

unread,
Nov 16, 2016, 12:21:26 AM11/16/16
to YALMIP
~ for unused output argument was introduced in MATLAB R2009b http://blogs.mathworks.com/loren/2009/09/11/matlab-release-2009b-best-new-feature-or/ .
Reply all
Reply to author
Forward
0 new messages