Home > Back-end >  Matlab genetic algorithm called ansys
Matlab genetic algorithm called ansys

Time:11-03

Younger brother do a matlab genetic algorithm master called ansys calculation class set, using matlab ga function of the toolbox, state variables are calculated by ansys, using nonlcon constraints, but found that after the run iteration speed is slow, don't know where genetic algorithm make wrong, I now posted code, every brother please give advice or comments!!

CodePudding user response:

The function optimization4 ()
A=[]; B=[];
Aeq=[]; Beq=[]; LB=[0.1, 0.03, 0.03, 0.1, 0.03, 0.03]. UB=[0.4, 0.06, 0.06, 0.4, 0.06, 0.06].
Nvars=6;
The options=gaoptimset (' TimeLimit 'inf' PlotFcns, {@ gaplotbestf}, 'PopulationSize, 10,' broke ', 15, 'PopInitRange' [0, 0.6]).
[x, fval, exitflag]=ga (@ fitnessfcn4, nvars, A, b, Aeq, beq, LB, UB, @ nonlcon3, options)
The function y=fitnessfcn4 (x)
Y=x (1) (2) + 0.38 * * x x (3) + x (4) (5) + 0.2 * * x x (6);
Yet the function [c ceq]=nonlcon3 (x)
Fid=fopen (' NMSL. TXT ', 'w +');
Fprintf (fid, '% 6.2 f % 6.2 f % 6.2 f % 6.2 f % 6.2 f % 6.2 f \ n', x ');
The fclose (fid);
! The SET KMP_STACKSIZE=2048 k & amp; "C: \ Program Files " \ "ANSYS Inc" v150 \ bin \ winx64 \ \ ANSYS ansys150 - b - p struct - I C: \ Users \ Administrator \ bett MAC - o C: \ Users \ \ Administrator \ temp. TXT
Fid=fopen (' C: \ Users \ Administrator \ result TXT ', 'r');
Tline=fgetl (fid);
Y=str2num (tline);
The fclose (fid);
C (1)=y (1) - 1.41 e8;
C (2)=abs (y (2)) - 2 e8;
(3)=c abs (y) (3) - 2.7 e8;
C (4)=1.2 e6 - y (4);
Ceq=[];

CodePudding user response:

This is the younger brother of my code, please, grant instruction! Be very grateful!

CodePudding user response:

Most are rarely involved in matlab programming, and does not involve the use of ansys, come on,

CodePudding user response:

I also want to MATLAB algorithm to optimize the ANSYS, I haven't been successful,,,, the building Lord refueling ah
But before it pure genetic algorithm, genetic algorithm (ga) optimization itself required length is very long, if BP optimization to 1 min, genetic optimization may be 30 min, may be because the algorithm of the problem??
  • Related