PSO does not satisfy the nonlcon inequality constraint and gives solutions less than LB

2 views (last 30 days)
Hello everyone,
when running the pso with:
[best_solution, fval] = pso(objFcn,nVars,[],[],A_eq,B_eq,LB(ttt,:),UB(ttt,:),nonlcon,options_pso)
returns me solutions does not satisfy the nonlcon and some solutions have values lower than than the LB ?
here is the nonlcon function:
function [cneq, ceq] = myNonLinearConstraint(force_pop)
global ttt
% compression and shear vectors directions
[a1, b1, c1, a2, b2, c2, a, b, c, d, e, f] = shear_comp_ratio_coef;
% GH reaction forces
R_gh_x = force_pop(55);
R_gh_y = force_pop(56);
R_gh_z = force_pop(57);
% shear forces
F_shear_1 = a1(ttt)*R_gh_x+b1(ttt)*R_gh_y+c1(ttt)*R_gh_z;
F_shear_2 = a2(ttt)*R_gh_x+b2(ttt)*R_gh_y+c2(ttt)*R_gh_z;
% angle between F_shear_1 (as x-dir) and F_shear_2 (as y-dir)
theta = atan2d(F_shear_2,F_shear_1);
if theta<0
theta = theta+360;
end
% emprical shear_comp_ratio
shear_comp_ratio_emprical = [0.51, 0.33, 0.29, 0.4, 0.56, 0.43, 0.3, 0.35, 0.51];
angle = 0:45:360;
% get the shear_comp_ratio_at the current angle theta using linear interpolation
shear_comp_ratio_at_theta = interp1(angle,shear_comp_ratio_emprical,theta);
% total shear force
F_shear = (a(ttt)*R_gh_x+b(ttt)*R_gh_y+c(ttt)*R_gh_z);
% compression force
F_comp = (d(ttt)*R_gh_x+e(ttt)*R_gh_y+f(ttt)*R_gh_z);
% cneq: not equality constraint
cneq = abs(F_shear/F_comp)-shear_comp_ratio_at_theta;
% ceq: equality constraint not exist
ceq = [];
thanks in advance
  9 Comments

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 2 Jun 2023
Have you considered using the particleswarm function in Global Optimization Toolbox, either as your main solver or to help you diagnose why the solver in the File Exchange submission doesn't give you the answers you expect?
  8 Comments
Matt J
Matt J on 4 Jun 2023
Edited: Matt J on 4 Jun 2023
But again, you shouldn't be allowing these 2 different solutions to exist. Add a roughness penalty or something to your objective function..
Taha
Taha on 4 Jun 2023
My problem is a redundant problem, 34 equations with 69 unknowns, mathematically there are infinite number of solutions , I used the optimization technique and the constraints to reach to the best solution. There is big difference in ga and ps results , but both have the same trend. The point of enforcing the ga() to get smooth solutions I think it's very hard to do that. Anyway, I will try in this way.

Sign in to comment.

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!