How to solve this problem? Error using == Quadratic constraints not supported
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Intho Nurshauma Syuhri
am 17 Sep. 2020
Beantwortet: Walter Roberson
am 19 Sep. 2020
Hi everyone
I have a optimazation problem using "optimproblem". The problem is constraint. The constraint I need is x*x + y*y ==1.
x = optimvar('x');
y = optimvar('y');
prob = optimproblem;
prob.Objective = (((x*((K*x)+(K*y)))+(y*((K*x)+(K*y)))) - ((2*F*x))+((2*F*y)));
prob.Constraints.cons1 = x*x + y*y == 1;
sol = solve(prob);
The error messages as follows
Error using ==
Quadratic constraints not supported.
error in ..... (Line 237)
prob.Constraints.cons1=x*x + y*y ==1;
could you help me to fix this problem?
Thanks! Intho
0 Kommentare
Akzeptierte Antwort
Abdolkarim Mohammadi
am 17 Sep. 2020
Bearbeitet: Abdolkarim Mohammadi
am 17 Sep. 2020
QP = Quadradic Programming = Quadradic objective function and linear constraints.
QCQP = Quadratically Constrained Quadratic Programming = Quadradic objective function and quadradic constraints.
quadprog() solves QP problems, but you are defining a QCQP problem. QCQP can be solved using the combination of quadprog() and fmincon() as described in the following:
0 Kommentare
Weitere Antworten (1)
Walter Roberson
am 19 Sep. 2020
x*x + y*y == 1
Reduce the number of variables by replacing y with +/- sqrt(1-x^2) . Run twice, once with y being the positive root, and once with y being the negative root, and choose the best of the two.
If K and F are independent of x and y, then you can use calculus: differentiate with respect to x and solve for the zeros.
The roots for the + and - branch come out nearly exactly the same. Both of the branches have roots
(-F +/- sqrt(-F^2 + 2*K^2))/(2*K)
The + branch has root -1/sqrt(2) and the - branch has root +1/sqrt(2)
You would want to verify that these roots are indeed minima and not maxima.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Quadratic Programming and Cone Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!