I am trying to use the function fmincon for multiple nonlinear inequality constraints, and the output given does not satisfy all the inequality constraint

7 visualizzazioni (ultimi 30 giorni)
objective = @(x) - 16000*x(1)^2 - 32000*x(2)^2 - 40000*x(3)^2;
x0 = [0.05, 0.05, 0.07];
A = [];
b = [];
aeq = [1,1,1];
beq =0.6;
lb = [0.05, 0.05, 0.07];
ub = [];
nonlincon = @nlcon;
fmincon(objective, x0, A,b,aeq,beq,lb,ub,nonlincon,options)
output: 0.2833 0.0500 0.2667
c(1) = 16000*x(1)^2 - 1000 = 284.44444 %(which is not less than 0)
function [c,ceq] = nlcon(x)
c(1)= 16000*x(1)^2 - 1000;
c(2)= 32000*x(2)^2 - 1500;
c(3)= 40000*x(3)^2 - 2000;
end
  2 Commenti
Matt J
Matt J il 16 Mag 2022
Works fine for me:
objective = @(x) - 16000*x(1)^2 - 32000*x(2)^2 - 40000*x(3)^2;
x0 = [0.05, 0.05, 0.07];
A = [];
b = [];
aeq = [1,1,1];
beq =0.6;
lb = [0.05, 0.05, 0.07];
ub = [];
nonlincon = @nlcon;
x=fmincon(objective, x0, A,b,aeq,beq,lb,ub,nonlincon)
Local 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.
x = 1×3
0.1599 0.2165 0.2236
c1 = 16000*x(1)^2 - 1000
c1 = -590.9768
function [c,ceq] = nlcon(x)
c(1)= 16000*x(1)^2 - 1000;
c(2)= 32000*x(2)^2 - 1500;
c(3)= 40000*x(3)^2 - 2000;
ceq=[];
end

Accedi per commentare.

Risposte (1)

Matt J
Matt J il 16 Mag 2022
Modificato: Matt J il 16 Mag 2022
As a general rule, you should avoid nonlinear constraints when they have a linear equivalent. In your case, the nonlinear constraints can be re-expressed as simple bounds:
objective = @(x) - 16000*x(1)^2 - 32000*x(2)^2 - 40000*x(3)^2;
x0 = [0.05, 0.05, 0.07];
A = [];
b = [];
aeq = [1,1,1];
beq =0.6;
lb = [0.05, 0.05, 0.07];
ub = sqrt( [1000, 1500, 2000]./[16000,32000,40000] );
x=fmincon(objective, x0, A,b,aeq,beq,lb,ub)
Local 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.
x = 1×3
0.1599 0.2165 0.2236

Categorie

Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by