Quadratic Constraints/Optimization error in Matlab 2020b but not Matlab 2020a
14 views (last 30 days)
Show older comments
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.
2 Comments
Matt J
on 8 Sep 2021
I can't reproduce that error. Tell us the output of
>> which -all strjoin
on the R2020b machine.
Answers (1)
Matt J
on 10 Sep 2021
Was MATLAB running an old version of strjoin.m that was incompatible with the problem based optimization?
Yes, it appears that way.
0 Comments
See Also
Categories
Find more on Get Started with Optimization Toolbox 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!