How to set the maximum iteration parameters

577 views
Skip to first unread message

WMT_Azura

unread,
Jun 7, 2018, 12:01:18 AM6/7/18
to YALMIP

I am new to YALMIP, and I want to solve a MILP problem. The figure below shows the result of my solution. I don't know what it means, and I want to know how do set the maximum number of iterations.I would be very grateful if anyone could give me an enthusiastic reply.


WMT_Azura

unread,
Jun 7, 2018, 12:51:45 AM6/7/18
to YALMIP
I think it is most likely to be a modeling problem. If you can, please help me look at the modeling program. This problem has been bothering me for a long time and I hope it can be solved

And my data and project:


X = binvar(21, 21, 'full');

X1 = binvar(1, 21);

X2 = binvar(1, 21);

T = sdpvar(1, 21);


N
= 21;

Ns = 21;

Nc = 2;


sdpvar a1 a2;

intvar nm;

Nmin = [1 <= nm <= 21, uncertain(nm)];

A1 = [0 <= a1 <= 1, uncertain(a1)];

A2 = [0 <= a2 <= 1, uncertain(a2)];


R1 = csvread('snakes.csv');

R2 = csvread('locations.csv');

var = csvread('variances.csv');


Objective = sum(T);

Constraints = [sum(X1) >= a1 * N, sum(X2) <= a2 * N];


n=0;

for j = 1: 21

 for k = 1: N-1

       Constraints = [Constraints, X(j, R1(j, k+1)) <= X(j, R1(j, k))];

   end

   Constraints = [Constraints, X1(1, j) <= X(:, j) <= 21 * X1(1, j)];

   Constraints = [Constraints, X2(1, j) <= X(:, j) <= Ns * X2(1, j) + 1];

end


for i = 1:21

   n = n + X(i, R1(i, 1));

   Constraints = [Constraints, sum(X(i, :)) >= nm * X(i, R1(i, 1))];

   m=0;

   for j = 1: 21

       for l = 1:21

           if l ~= j

               m = m + X(i, l);

           end

       end

       Constraints = [Constraints, T(1, i) >= (X(i, j) * R2(i, j) + X(i, j) - m) * (R2(i, j) * Var(i, R2(i, j)))];

   end

end

Constraints = [Constraints, n == Nc];

options = sdpsettings('verbose', 2, 'showprogress', 1, 'solver', 'cplex');

sol = optimize(Constraints, Objective, options);


if sol.problem == 0

   sol_x = value(X);

   sol_x1 = value(X1);

   sol_x2 = value(X2);

   sol_t = value(Objective);

   dlmwrite('X.csv', sol_x);

else

   sol.info

   yalmiperror(sol.problem)

end




Data and Project.zip

Johan Löfberg

unread,
Jun 7, 2018, 2:56:36 AM6/7/18
to YALMIP
The display shows that you are setting up a nonlinear integer program, and the only solver YALMIP can use is bnb (veeeeery slow), as you have nothing else available. bnb finds no solution as the upper bound is inf. You alter the iteration limit with bnb.maxiter

Johan Löfberg

unread,
Jun 7, 2018, 3:04:45 AM6/7/18
to YALMIP
You are trying to use cplex, but you never send the options structure to optimize

However, if you had cplex installed, and the problem was possible to solve using cplex, YALMIP would have picked cplex

The reason YAMIP thinks this is a nonconvex nonlinear program is because you never add the Nmin, A1 and A2 constraitns to the model. Hence, YALMIP thinks nm is a decision variable, which leads to bilinear constraints

Fixing everything, and a MILP solver immediately detects that the problem is infeasible

WMT_Azura

unread,
Jun 7, 2018, 3:45:16 AM6/7/18
to YALMIP
Firstly, thank you so much for your timely reply.

After I installed cplex and add the Nmin, A1 and A2 constraints, cplex solver immediately display the follow result. I do not understand why the problem is infeasible. And I tried the steps in your post about debugging the infeasible solutions. But I still can't solve the problem. Is there something wrong with my modeling?

options = sdpsettings('verbose', 2, 'showprogress', 1, 'solver', 'cplex');

sol = optimize(Constraints+Nmin+A1+A2, Objective, options);


In addition, my current work is a paper, the paper indicates that the model can be regarded as a linear model and can close to the optimal solution by using cplex, the following screenshots is a few words of words in the paper:



Johan Löfberg

unread,
Jun 7, 2018, 6:11:39 AM6/7/18
to YALMIP
I strongly doubt that the problem you solve as a robust optimization problem really is intended to be solved as such. The robustified model is trivial [sum(X1) >= N, sum(X2) <= 0]  which immediately says X1=1 and X2=0

WMT_Azura

unread,
Jun 8, 2018, 1:33:28 AM6/8/18
to YALMIP

May be you are right. According to the mathematical expression of the model in the screenshot above, Nmin, a1, and a2 should be constants. The paper about a1 and a2 just shows that if it is set to 1 and 0 will lead to infeasible, but not specifically set how much, so I set it as uncertain parameters.

I tried to set them to constants, such as N_min = 2, a1 = 0.5, a2 = 0.5, however, there is still no feasible solution to the problem. 

I try to contact the author of the next paper, how to set these three constants.

Anyway, thank you so much for your reply! I 

Johan Löfberg

unread,
Jun 8, 2018, 2:35:22 AM6/8/18
to YALMIP
You can turn them all off by setting a1 = 0;a2 = 1;nm = 0;, and the problem is still infeasible

It is feasible until you add n == Nc. 

To see how far off from feasibility you are, you can skip that constraint, and minimize abs(n-Nc), and you will see that the minimum value of that expression is 1, i.e. the constraint is impossible while satisfying all the other constraints



Reply all
Reply to author
Forward
0 new messages