Genetic Algorithm and FEA

1 回表示 (過去 30 日間)
Lomalsvi Bischerre
Lomalsvi Bischerre 2021 年 1 月 19 日
コメント済み: Mario Malic 2021 年 1 月 20 日
I am trying to do an optimization of a structure using GEnetic Algorithm. I wrote the MATLAB code for the fitness function below but it produces an error. The structure is designed in ANSYS.
L is the variable that will be read in from an input file. The file Stress.txt is the output of the ansys code wich will be read and used by the GA solver. I tried using the GA Toolbox GUI here.
function y = fitness(l)
l1=abs(l(1));
l2=abs(l(2));
fid=fopen('length.inp');
fprintf(fid,'l1=%f\n',l1);
fprintf(fid,'l2=%f\n',l2);
fclose(fid);
SET KMP_STACKSIZE=4096k & "C:\Program Files\ANSYS Inc\v192\ansys\bin\winx64\ANSYS192.exe" -b -p -i "C:\Users\Asus\Desktop\ANSYS\ansys_files\ansys_file.txt" -o "C:\Users\Asus\Desktop\Intro to ANSYS\ansys_files\output.txt"
fid=fopen('Stress.txt','r');
stress=fscanf(fid,'%f',[1,1]);
fclose(fid);
if((stress/250)<1)
y=(stress/250);
else
y=10000000;
end
Please help me find the cause of the error
  1 件のコメント
Mario Malic
Mario Malic 2021 年 1 月 20 日
It's hard to tell without knowing what's the error. The line with "SET" may be wrong syntax.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by