solve function is not working in R2022a Update 5
Show older comments
Hi :)
After updating to R2022a Update 5 version of MATLAB, the "solve" function is not working as it did before.
Diagnozing the problem should start with getting the minimal working example, so I "copy-pasted" the short code from MATLAB Documentation on function "solve" (see below). Unexpectedly, running this code resulted in exactly the same error message, as the one I get while running my own program.
I would appreciate your comments and hints on this case.
Thank you,
Grzegorz
Here is the code "copy-pasted" from MATLAB Documentation:
x = optimvar('x');
y = optimvar('y');
prob = optimproblem;
prob.Objective = -x - y/3;
prob.Constraints.cons1 = x + y <= 2;
prob.Constraints.cons2 = x + y/4 <= 1;
prob.Constraints.cons3 = x - y <= 2;
prob.Constraints.cons4 = x/4 + y >= -1;
prob.Constraints.cons5 = x + y >= 1;
prob.Constraints.cons6 = -x + y <= 2;
sol = solve(prob)
Here is the error message:
Solving problem using linprog.
ERROR - (linprog): problem must contain at least "f", "A" and "b".
Error using optim.problemdef.OptimizationProblem/solve
Output argument "x" (and possibly others) not assigned a value in the execution with "linprog" function.
7 Comments
Bruno Luong
on 4 Sep 2022
Work for me
>> x = optimvar('x');
y = optimvar('y');
prob = optimproblem;
prob.Objective = -x - y/3;
prob.Constraints.cons1 = x + y <= 2;
prob.Constraints.cons2 = x + y/4 <= 1;
prob.Constraints.cons3 = x - y <= 2;
prob.Constraints.cons4 = x/4 + y >= -1;
prob.Constraints.cons5 = x + y >= 1;
prob.Constraints.cons6 = -x + y <= 2;
sol = solve(prob)
Solving problem using linprog.
Optimal solution found.
sol =
struct with fields:
x: 0.6667
y: 1.3333
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.12.0.2039608 (R2022a) Update 5
Grzegorz Dzierzanowski
on 5 Sep 2022
SamVector
on 2 Mar 2024
Hello? Has the problem been solved?
Matt J
on 2 Mar 2024
@SamVector Yes, the problem has been solved.
Walter Roberson
on 2 Mar 2024
which -all solve
SamVector
on 3 Mar 2024
Thanks. Although I have no idea how the problem has been solved, The problem vanished after I reinstall the Optimization toolbox. I think it may be conflit with the matpower toolbox I installed.
Answers (0)
Categories
Find more on Linear Programming and Mixed-Integer Linear Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!