Solving equation problem with constrains using the Optimization Toolbox

4 views (last 30 days)
MENGZE WU on 12 Nov 2021
Commented: Matt J on 12 Nov 2021
I have a problem with handful of variables and constrains, it look a lot like this one:
However, instead of finding the minimum cost like the problem above, I already have a target cost, but find the variables that fits this target cost. So I look at the equation problems:
But it seems that the equation problem wouldn't allow me to add constrains, what should I do?

Accepted Answer

Matt J
Matt J on 12 Nov 2021
Edited: Matt J on 12 Nov 2021
Use your first approach except specify a least squares objective, like below.
target=10; %target cost
solve( optimproblem('Objective', (x+2*y-target).^2,'Constraints',con) )
Solving problem using lsqlin. Minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
ans = struct with fields:
x: 3.8238 y: 3.0881
Be mindful, however, that the solution will probably be non-unique. For example, another solution to the example problem above is x=10, y=0.
Matt J
Matt J on 12 Nov 2021
If the set of solutions is all points on a particular line or particular plane, then you cannot return them all
No, you can't, but it will be a convex polyhedral region and, if bounded, you can use its vertices both to plot the region and to sample an arbitrary number of points from its interior.

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!