Hardstop intlinprog & return the current solutions

조회 수: 8 (최근 30일)
Samyak Singh
Samyak Singh 2021년 10월 22일
댓글: Samyak Singh 2021년 10월 25일
Hi,
I am trying to use intlinprog to optimize a production schedule for three different goods with six different product configuration. I have used the problem-based approach for my solution & I am pretty confident on correctness of my code. I would like to hardstop intlinprog after some iterations of Branch & Bound.
I tried changing the MaxTime & RelativeGapTolerance using optimoptions, but I am getting errors all the time. I think I am not able to correctly associate the options in the problem structure. Can somebody help me with that.
An example code snippet to illutrate the problem is-:
x = optimvar('x');
y = optimvar('y');
prob = optimproblem;
f = exp(x)*(8x+3y + 1);
prob.Objective = f;
cons1 = x + y >= 1.5;
cons2 = 5x-3y >= -10;
prob.Constraints.cons1 = cons1;
prob.Constraints.cons2 = cons2;
z=prob2struct(prob);
soln=intlinprog(z);
Note-: This is not my code, just included an example so that someone can show me how to integrate options in intlinprog when input is problem structures.
Questions-:
1) Can someone show me how to change the default Maxtime or relative tolerance to stop the run after some iterations & return the current values of variable?
2) I read somewhere that default MaxTime for intlinprog is 7200 hrs. So shouldn't the program stop after that time & give you the current results automatically?
  댓글 수: 2
Matt J
Matt J 2021년 10월 22일
편집: Matt J 2021년 10월 22일
Could you modify your example so that it reproduces the difficulty? The example has no integer-constrained variables, so I think intlinprog will just fall back to linprog.
Samyak Singh
Samyak Singh 2021년 10월 25일
Hi,
Thank you for your answer. Unfortunately, I cannot post my code here because of confidentiality reasons, but I figured out the solution from Alan's answer.

댓글을 달려면 로그인하십시오.

채택된 답변

Alan Weiss
Alan Weiss 2021년 10월 22일
편집: Alan Weiss 2021년 10월 22일
You don't have to call prob2struct to solve your problem. Just call
[sol,fval] = solve(prob,'Options',opts)
Now, what should opts contain? Try this:
opts = optimoptions('intlinprog','MaxNodes',1e5); % The default value is 1e7
I don't know whether this will give you what you want, but it sounds like what you have been trying. You could also try
opts = optimoptions('intlinprog','MaxTime',10*60); % 10 minutes instead of 120
For options details, see intlinprog options. You could also consult Tuning Integer Linear Programming.
Alan Weiss
MATLAB mathematical toolbox documentation
  댓글 수: 1
Samyak Singh
Samyak Singh 2021년 10월 25일
Hi,
Thank you Alan for your answer. It worked for me wonderfully. Earlier, I was trying to pass optimoptions & problem structure as input to intlinprog, which as you know was not working out well for me.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by