Quadratic Constraints/Optimization error in Matlab 2020b but not Matlab 2020a
이전 댓글 표시
Hi, I have Matlab 2020a and 2020b in different computers. My codes to run quadratic optimization (quadratic objective function, quadratic constraints) run into error in the newer version but not the older version of Matlab.
Here is an example: I wrote the following code to find the shortest distance between two circles:
%%% Define the Optimization Problem
CircleDistance = optimproblem;
%%%%% variables
x1 = optimvar('x1' , 1);
y1 = optimvar('y1' , 1);
x2 = optimvar('x2' , 1);
y2 = optimvar('y2' , 1);
% Constraints
CircleDistance.Constraints.Circle1 = x1.^2 + y1.^2 <= 5;
CircleDistance.Constraints.Circle2 = (x2-10).^2 + (y2-5).^2 <= 5;
% Objective Function
CircleDistance.Objective = (x1-x2).^2 + (y1 -y2).^2;
% Initial Point
x0.x1 = 0;
x0.y1 = 0;
x0.x2 = 10;
x0.y2 = 5;
% Solve the problem
x = solve(CircleDistance, x0);
In Matlab 2020a, I get the correct solution (as listed above), but I get the following error when I run the code in Marlab 2020b (on a different computer).
Error using strjoin (line 38)
The first argument should be a cell array of strings.
Error in optim.internal.problemdef.compile.compileQuadraticConstraints
Error in optim.problemdef.OptimizationProblem/compileConstraints
Error in optim.internal.problemdef.ProblemImpl/prob2structImpl
Error in optim.internal.problemdef.ProblemImpl/solveImpl
Error in optim.problemdef.OptimizationProblem/solve
Error in Untitled (line 27)
x = solve(CircleDistance, x0);
Can someone help me out please? Thank you in advance.
답변 (1개)
Matt J
2021년 9월 10일
0 개 추천
Was MATLAB running an old version of strjoin.m that was incompatible with the problem based optimization?
Yes, it appears that way.
카테고리
도움말 센터 및 File Exchange에서 Quadratic Programming and Cone Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!