the command linprog is incosistent when i use 'X0'
9 views (last 30 days)
Show older comments
I get this error "Error using linprog
LINPROG(f,A,b,Aeq,beq,LB,UB,X0) does not accept X0. Use
LINPROG(f,A,b,Aeq,beq,LB,UB) instead.
Error in problema1otmizacao (line 66)
[x,fval,exitflag] = linprog(f,A,b,Aeq,beq,lb,ub,x0); "
How can I solve this?
0 Comments
Answers (3)
the cyclist
on 12 Apr 2023
I'm looking at the online documentation for linprog (which if for version R2023a), and I don't see a valid calling syntax that corresponds to
linprog(f,A,b,Aeq,beq,lb,ub,x0)
You don't specify what version you are using. I don't know if the way you are calling linprog is valid in an older version.
2 Comments
Walter Roberson
on 12 Apr 2023
It was documented in R2022b in the help, but not in the doc, and the help said it applied only to active-set. The R2022b code in practice gives a warning for all use of x0 (for all algorithms).
Walter Roberson
on 13 Apr 2023
There are a few different possibilities here:
- if your code relies on the ability to set an initial point, such as code that runs the algorithm from several different starting points to try to find the best solution, then you can revert to an earlier version of MATLAB in which the code paid attention to the value. I am not sure which version that would be: I know that R2018b did not pay attention to the value
- if your code is only executing linprog once and you did not have special reason for choosing the particular x0, and you are permitted to do so, just remove the x0 from the call
- if you are required to keep that x0 by someone (for example a course that will reject your solution if you do not use that exact calling sequence) then implement your own linprog function specifically just to work around the issue. If you are fortunate then you would be able to reuse portions of the internal implementation
- or in such a situation you could approach the person who imposed the requirement that the x0 be present and point out to them that it has not been a meaningful parameter for at least 5 years and ask them to permit the call without the x0 parameter
- there is always the option of approaching Mathworks and paying them a couple of million dollars to do an urgent upgrade release to once more accept and silently ignore the x0 parameter.
2 Comments
Matt J
on 13 Apr 2023
if your code relies on the ability to set an initial point, such as code that runs the algorithm from several different starting points to try to find the best solution,
But it shouldn't, because linear programs have no sub-optimal local minima.
Walter Roberson
on 13 Apr 2023
It is not out of the question for someone to be assigned a programming task to investigate how using different x0 affects the output for different fitting algorithms.
Matt J
on 13 Apr 2023
Edited: Matt J
on 13 Apr 2023
If x0 is known to be feasible, you might be able to influence the speed of convergence by modifying your constraints as below;
f=f(:).'; %ensure row
[x,fval,exitflag] = linprog(f,[A;f],[b;f*x0];,Aeq,beq,lb,ub)
if exitflag<0
x=x0;
end
This tells the optimization to ignore points worse than x0.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!