Optimizing a parametrized geometry with genetic algorithm

7 vues (au cours des 30 derniers jours)
Kim
Kim le 24 Août 2022
Modifié(e) : Kim le 24 Août 2022
Hello,
My current working state is as follows: I build the geometry in Matlab, export it to Comsol where the FE-Calculation takes place and afterwards I can retrieve the results such as reaction force in Matlab.
My aim is to optimize the geometry in order to get the maximum reaction force. Therefore I want the genetic algorithm to vary the geometric parameters, here for example A. In total there are up to ten, but I'm trying it with one first. If I write
Fmax = @(A)FE_Calculation;
A = optimvar("A","LowerBound",1,"UpperBound",1.5);
I don't succeed in plotting
T0=0.75;
m=472.5;
s=linspace(0,m,m+1);
y2= A .*rem(s/70,T0)./T0+ s/8;
figure(1);
plot(s,y2);
since A is continuous (Error message: "Data must be numeric, datetime, duration or an array convertible to double.") Unfortunately, I need this plot to generate my geometry.
Does anybody have a solution or an idea how to approach this?
I would be very grateful for your help.
  2 commentaires
Matt J
Matt J le 24 Août 2022
I don't succeed in plotting ...since A is continuous
No, A is not continuous. A does not possess value(s) at all!
Kim
Kim le 24 Août 2022
Modifié(e) : Kim le 24 Août 2022
Ok, I printed A at the command window and got
A=
OptimizationVariable with properties:
Name: 'A'
Type: 'continuous'
IndexNames: {{} {}}
LowerBound: 1
UpperBound: 1.5000
So I thought it would be 'continuous' but if it just discribes the distribution and A doesn't contain any values, it explains why the problem occures. There has to be a point somewhere in the algorithm, where they need actual values for the calculation. Or does this just happen in the final step of "solve"?

Connectez-vous pour commenter.

Réponses (1)

Matt J
Matt J le 24 Août 2022
Modifié(e) : Matt J le 24 Août 2022
Whn generating y2, your current code attempt doesn't make it clear what values you intend for "A". Perhaps this is what you meant,
y2= linspace(1,1.5,m+1) .*rem(s/70,T0)./T0+ s/8;
  1 commentaire
Kim
Kim le 24 Août 2022
If I change A, the form of the curve will change and so will my geometry. I just took the range of values for A between 1 and 1.5 as an example. I attached two pictures withe the influence of A on the geometry. You can see one with A=0.75 and one with A=3. So it's important for me to be able to integrate it in my optimization loop.

Connectez-vous pour commenter.

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by