maximum iterations for cplex

250 views
Skip to first unread message

Salamino15

unread,
Apr 14, 2015, 3:50:57 AM4/14/15
to yal...@googlegroups.com
Hi,

I need the parameter for setting the maximum number of iterations for cplex please. I am lost and can't find it!

Thanks :)

Johan Löfberg

unread,
Apr 14, 2015, 4:08:25 AM4/14/15
to yal...@googlegroups.com
You just have to search in the available settings. Number of iterations sounds like a weird thing to alter though (as it depends on the algorithm etc). More natural to alter max time.

>> ops = sdpsettings;
>> ops.cplex

ans
=

           advance
: 1
           barrier
: [1x1 struct]
         clocktype
: 2
          conflict
: [1x1 struct]
      dettimelimit
: 1.0000e+75
           distmip
: [1x1 struct]
          emphasis
: [1x1 struct]
           feasopt
: [1x1 struct]
          lpmethod
: 0
               mip
: [1x1 struct]
           network
: [1x1 struct]
            output
: [1x1 struct]
          parallel
: 0
     preprocessing
: [1x1 struct]
          qpmethod
: 0
        randomseed
: 201309011
              read
: [1x1 struct]
           sifting
: [1x1 struct]
           simplex
: [1x1 struct]
    solutiontarget
: 0
           threads
: 0
         timelimit
: 1.0000e+75
              tune
: [1x1 struct]
           workdir
: '.'
           workmem
: 2048
           display
: 'off'
       exportmodel
: ''


Salamino15

unread,
Apr 14, 2015, 4:17:45 AM4/14/15
to yal...@googlegroups.com
I am optimizing the code in blue below and I got this error in red below .. I'm not sure what to do.. I'm freaking out as I should submit a paper tomorrow and still have tons to do :'( I'm suspecting it's because there's no lower bound in the second constraint!!

fmincon stopped because it exceeded the function evaluation limit,
options.MaxFunEvals = 3000 (the default value).

ERROR!
problem!

ans =

     3

info!

ans =

Maximum iterations or time limit exceeded (FMINCON)

-----------------------------

function[min_total_LOU,unfair_power] = opt(ArrayUF,forecasted_power,max_saving,baseload,required_dr)

if sum(max_saving) < required_dr
     display('CANNOT COVER REQUIRED DEMAND REDUCTION - CHOOSE A BIGGER COALITION'); 
end

consumers = length(max_saving);
x = sdpvar(consumers,1);

saving = forecasted_power - x; 

%% Constraints
constraint = [baseload <x< forecasted_power,
             saving<=max_saving, 
             sum(saving)==required_dr];

%% Objective function
obj=0;
for i = 1:consumers
    obj = obj + sdpfun(forecasted_power(i),str2func(char(ArrayUF(i)))) - sdpfun(x(i),str2func(char(ArrayUF(i))));
end

options = sdpsettings('verbose',2);
sol = solvesdp(constraint,obj,options);
unfair_power = double(x);
min_total_LOU = double(obj);


Johan Löfberg

unread,
Apr 14, 2015, 4:23:26 AM4/14/15
to yal...@googlegroups.com
The error message rather clearly tells you that fmincon failed, so I have no idea why you are talking about cplex

Salamino15

unread,
Apr 14, 2015, 4:26:43 AM4/14/15
to yal...@googlegroups.com
never mind about cplex... I changed solvers a number of times!

how can I solve this problem please? :)

Johan Löfberg

unread,
Apr 14, 2015, 4:28:48 AM4/14/15
to yal...@googlegroups.com
Well, since fmincon was selected, it indicates that the problem is nonlinear and probably nonconvex, and possibly very hard or even impossible to solve in the worst case. Impossible to say anything without reproducible code.

Salamino15

unread,
Apr 14, 2015, 4:44:07 AM4/14/15
to yal...@googlegroups.com
the codes and test data are attached .. 

and below is the test script :)
thank youuuuuuuuuuuuuuu

consumers = 100;
required_dr = 250;
forecasted_power = xlsread('inputdata.xlsx',counter,cat(2,'$A2:$A',int2str(consumers+1)));
max_saving = xlsread('inputdata.xlsx',counter,cat(2,'$C2:$C',int2str(consumers+1)));
baseload = xlsread('inputdata.xlsx',counter,cat(2,'$D2:$D',int2str(consumers+1)));
ArrayUF = AssignUF (forecasted_power);
[min_total_LOU,unfair_power] = opt(ArrayUF,forecasted_power,max_saving,baseload,required_dr);

to yalmip.rar

Johan Löfberg

unread,
Apr 14, 2015, 4:55:37 AM4/14/15
to yal...@googlegroups.com
>> consumers = 100;
required_dr = 250;
forecasted_power = xlsread('inputdata.xlsx',counter,cat(2,'$A2:$A',int2str(consumers+1)));
max_saving = xlsread('inputdata.xlsx',counter,cat(2,'$C2:$C',int2str(consumers+1)));
baseload = xlsread('inputdata.xlsx',counter,cat(2,'$D2:$D',int2str(consumers+1)));
ArrayUF = AssignUF (forecasted_power);
[min_total_LOU,unfair_power] = opt(ArrayUF,forecasted_power,max_saving,baseload,required_dr);
Undefined function or variable 'counter'.
 

Salamino15

unread,
Apr 14, 2015, 5:04:15 AM4/14/15
to yal...@googlegroups.com
sorry

counter = 1

Johan Löfberg

unread,
Apr 14, 2015, 5:21:08 AM4/14/15
to yal...@googlegroups.com
Have you even looked at the result? From the display, it looks like fmincon converges nicely, and the final solution is feasible, so I would be happy with it (sure, first-order optimality is only down to 1e-4, but I would be ok with that). In particular considering the awkward way you have modeled the model. You seem to have a very simply sum of square-roots etc as objectives, but you hide this completely to fmincon by placing stuff in an sdpfun construction, thus forcing fmincon to work with a black-box representation of the objective (no derivatives). Even worse, you hide constant data inside sdpfun objects.

You objective appears to be constant - sum f_i where all the f_i are either sqrt or x^.4. Both those functions are concave and SOCP-representable, and you can thus put everything in an SOCP form which is convex and nicely behaved (using cpower)

Salamino15

unread,
Apr 14, 2015, 5:50:18 AM4/14/15
to yal...@googlegroups.com
Oh! So it turned out to be the bloody sdpfun!! Thank you :)

It was a bad idea to use function handles anyway.. not again.. lesson learnt!

Sorry I'm still a newbie to all of this, so can you give me any tips on how to automate putting the functions in an SOCP, as I have up to hundreds of functions to deal with...

Johan Löfberg

unread,
Apr 14, 2015, 5:53:50 AM4/14/15
to yal...@googlegroups.com
YALMIP automatically converts to socp if possible if you use sqrt or cpower

>> sdpvar x y
>> optimize([x + y == 1],-sqrt(x)-cpower(y,.4))


Reply all
Reply to author
Forward
0 new messages