Implementing a nonlinear constraint with fmincon
Show older comments
Hello, so my problem is implementing the condition such that c1*c4>0, c2*c5>0, and c3*c6>0
And so, when implementing in fmincon it makes sense to write it in a sense of (-1) * ci*cj <= 0
When implemented as this and calling the function handle
function [z, zeq] = nlcon_poly_ogden(c)
z = [-1*c(1)*c(4),-1*c(2)*c(5),-1*c(3)*c(6)];
zeq = [];
end
and calling @nlcon_poly_ogden in the problem declaration
nonlcon_ogden = @nlcon_poly_ogden
ogden_polyconvexity_gs_problem = createOptimProblem('fmincon', 'x0', r, 'objective', ***, ...
'lb',[],'ub',[],'nonlcon', nonlcon_ogden, 'Aeq', [], 'beq', [],'options', options);
run(gs, ogden_polyconvexity_gs_problem); % gs is a default GlobalSearch object
The resulting parameters are not satisfying the bounds.... is there something I am doing wrong?
11 Comments
And what are the resulting parameters and what are the bounds that are violated ?
And according to what you wrote, it should be
-1*c(2)*c(4)*c(5)
instead of
-1*c(2)*c(5)
Reed
on 5 Oct 2022
Torsten
on 5 Oct 2022
Maybe you work with less than 6 parameters while you address c(1),...,c(6) in nlcon_poly_ogden ?
Torsten
on 5 Oct 2022
Where is r ?
x = rand(20,1);
y = rand(20,1);
ogden_gs_func = @(c) sum((c(1)*(x.^(c(4)-1)-x.^((-1)/2*c(4)-1)) + ...
c(2)*(x.^(c(5)-1)-x.^(-1/2*c(5)-1)) + ...
c(3)*(x.^(c(6)-1)-x.^((-1)/2*c(6)-1))- y).^2);
upperbound = 5;
lowerbound = -5;
r =((lowerbound- upperbound).*rand(6,1)+ upperbound)';
options = optimoptions('fmincon', 'Algorithm','interior-point', 'MaxFunctionEvaluations', 10000, 'MaxIterations', 10000);
gs_constrained = GlobalSearch("StartPointsToRun","bounds-ineqs");
nonlcon_poly_ogden = @nlcon_poly_ogden;
ogden_polyconvexity_gs_problem = createOptimProblem('fmincon', 'x0', r, 'objective', ogden_gs_func, ...
'lb',lowerbound*ones(6,1),'ub',upperbound*ones(6,1),'nonlcon', nonlcon_poly_ogden, 'options', options);
[Global, fval, exitflag, output, solutions] = run(gs_constrained, ogden_polyconvexity_gs_problem);
function [z, zeq] = nlcon_poly_ogden(c)
z = [-1*c(1)*c(4),-1*c(2)*c(5),-1*c(3)*c(6)];
zeq = [];
end
Reed
on 5 Oct 2022
They are important because GlobalSearch refers to them ("bounds-ineqs"):
gs_constrained = GlobalSearch("StartPointsToRun","bounds-ineqs");
Reed
on 5 Oct 2022
Torsten
on 5 Oct 2022
I don't know of these specific settings - sorry.
Answers (0)
Categories
Find more on Surrogate Optimization 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!