solve function is not working in R2022a Update 5
이전 댓글 표시
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
Bruno Luong
2022년 9월 4일
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
2022년 9월 5일
SamVector
2024년 3월 2일
Hello? Has the problem been solved?
Matt J
2024년 3월 2일
@SamVector Yes, the problem has been solved.
Walter Roberson
2024년 3월 2일
which -all solve
SamVector
2024년 3월 3일
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.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!