problems with fmincon, how to solve?
Afficher commentaires plus anciens
can someone help me solve this problem, I tried to modify the code but it didn't solve it. I need to minimize the following equation.

objective function:
function cosmyfun(x)
cost = @(x) dfghjhgfx(1)^2 + x(2)^2 - 5*x(1) - 6*x(2) + 15;
end
function with restrictions of inequality and equality:
function [c,ceq]=mycon(x)
c(1) = x(1)^2 + x(2)^2 - 4*x(1) - 3*x(2) + 5;
c(2) = -x(1)^2 - x(2)^2 + 4*x(1) + 3*x(2) - 10;
ceq = 2*x(1)^2 + 2*x(2)^2 - 3*x(1) - 3*x(2) - 2;
end
script:
clc
clear all
Aeq=[];
beq=[];
A=[];
b=[];
lb=[-3,-3];
ub=[3,3];
x0=[4,4];
options = optimoptions('fmincon','Algorithm','sqp','Display','iter-detailed','MaxFunctionEvaluations',100000, 'MaxIterations',2000, 'OptimalityTolerance' ,1e-10);
[x,cost] = fmincon(@(x) myfun,x0,A,b,Aeq,beq,lb,ub,mycon)
error:
Error in mycon (line 2)
c(1) = x(1)^2 + x(2)^2 - 4*x(1) - 3*x(2) + 5;
Error in Example (line 11)
[x,cost] = fmincon(@(x) myfun,x0,A,b,Aeq,beq,lb,ub,mycon)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!