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
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
Grzegorz Dzierzanowski 2022 年 9 月 5 日
Thank you, Bruno.
My guess is that the third-party software, which I am using with MATLAB, overloads the original solve command.
Anyway, thanks for your comment.
Best,
Grzegorz
SamVector
SamVector 2024 年 3 月 2 日
Hello? Has the problem been solved?
Matt J
Matt J 2024 年 3 月 2 日
@SamVector Yes, the problem has been solved.
SamVector
SamVector 2024 年 3 月 2 日
編集済み: SamVector 2024 年 3 月 2 日
Excuse me, but I faced the same problem lately, and I want to know how exactly did you do to solve the problem? Which third party software is likely to cause the trouble? Thanks in advance🙏
Walter Roberson
Walter Roberson 2024 年 3 月 2 日
which -all solve
SamVector
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 ExchangeLinear Programming and Mixed-Integer Linear Programming についてさらに検索

製品

リリース

R2022a

タグ

質問済み:

2022 年 9 月 4 日

コメント済み:

2024 年 3 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by