Skip to content

Commit ee58eaa

Browse files
Fix parameters for cantilever beam optimization.
In case the GA can't find the constraints of the optimal solution, it will return NaN.
1 parent 1dba3e3 commit ee58eaa

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

COSSANXengine/examples/Tutorials/CantileverBeam/TutorialCantileverBeamMatlabOptimization.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
Xsqp = SequentialQuadraticProgramming('finitedifferenceperturbation',0.01);
164164
Xcobyla = Cobyla();
165165
Xga = GeneticAlgorithms('Smutationfcn','mutationadaptfeasible','NmaxIterations',50, ...
166-
'NPopulationSize',200);
166+
'NPopulationSize',20);
167167

168168
%% Optimization: Setup
169169
% Reset the random number generator in order to always obtain the same

COSSANXengine/src/optimization/@GeneticAlgorithms/apply.m

+5-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,11 @@
245245
Vindex=all(XoptGlobal.TablesValues.DesignVariables==XoptGlobal.VoptimalDesign,2);
246246
Mdataout=XoptGlobal.TablesValues.Constraints(Vindex);
247247
Vpos=find(all(~isnan(Mdataout),2));
248-
XoptGlobal.VoptimalConstraints=Mdataout(Vpos(1),:);
248+
if ~isempty(Vpos) > 0
249+
XoptGlobal.VoptimalConstraints = Mdataout(Vpos(1),:);
250+
else
251+
XoptGlobal.VoptimalConstraints = NaN(1, length(Xop.Xconstraint));
252+
end
249253
end
250254

251255
Xoptimum=XoptGlobal;

0 commit comments

Comments
 (0)