running a project using genetic algorithm

조회 수: 1 (최근 30일)
Hamid
Hamid 2014년 8월 6일
댓글: Hikaru 2014년 8월 11일
I want to run a project using genetic algorithm and I don't know how.
This project have 4 functions that I attached this thesis here.
functions m files are in this thesis.
thank you guys.
  댓글 수: 2
Hikaru
Hikaru 2014년 8월 6일
Copy the functions into an m-file. Save the 4 functions in separate m-files. While copy-and-pasting, the lines might have change, you have to check that syntax are all ok. Then click run (green play button) or type the function name in the command window.
Hikaru
Hikaru 2014년 8월 7일
편집: Hikaru 2014년 8월 7일
I'm assuming that the 4 functions you meant are:
  • GAmodule (pg 43-48)
  • penalty2 (pg 49-50)
  • bintranslate (pg 51-53)
  • FEM2 (pg 54-56)
If so, it's better not to combine them. Make separate m-files, and make sure you have them all on your working directory.
If it does not work, then you should CHECK the syntax. I'm pretty sure the lines could change during copy-and-pasting. MATLAB reads code in one line, unless if there are ellipses (...) at the end to tell it to check the next line before execution. In the editor, you should see red bars that will point you to the lines with problem.
If you did all this and it still doesn't work, you should tell us what does the error message say.
You said, "does NOT worked", then tell us WHAT does not work.

댓글을 달려면 로그인하십시오.

채택된 답변

Hikaru
Hikaru 2014년 8월 7일
Try changing the first line in all your files.
.m should start with:
function GAmodule
And penalty2.m should start with:
function [fitness]=penalty2(chromosome,available,bc,Dof,E,f,fixedcoord,na,nb,neft,ne,vt,nl,nn,numbitCoordX,numbitCoordY,numbitEdof,numbitEp,sq,TOPGSM,xspan,yspan);
And bintranslate.m should start with:
function [Coord,Edof,Ep]=bintranslate(available,chromosome,Dof,fixedcoord,na,nb,neft,nevt,nl,nn,numbitCoordX,numbitCoordY,numbitEdof,numbitEp,xspan,yspan);
And FEM2.m should start with:
function [Ed,Ex,Ey,v1,v2,w,wrong]=FEM2(bc,Coord,Dof,E,Edof,Ep,f,neft,nevt,sq,TOPGSM);
  댓글 수: 5
Hikaru
Hikaru 2014년 8월 11일
Please re-download the files FEM2.m and GAmodule.m in my previous comment. I made a slight change in FEM2.m in line 65, which should be
if isnan(rcond(K))
and in line 98 of GAmodule.m, I removed the number 2, such that it becomes
'PlotFcns', {@gaplotbestf},...
I used the numbers in the benchmark problem as outlined in pg 29-30.
Please specify which steel quality You intend to use [N/mm^2](235/275/355/420/460)! 235
Please specify the number of support nodes! 2
Please specify the number of nodes affected by a load! 2
Please specify the total number of nodes! 6
Please specify the X-coordinate of support node1! (dm) 0
Please specify the Y-coordinate of support node1! (dm) 0
Please specify the X-coordinate of support node2! (dm) 0
Please specify the Y-coordinate of support node2! (dm) 91.44
Please specify the X-coordinate of load node1! (dm) 91.44
Please specify the Y-coordinate of load node1! (dm) 0
Please specify the X-coordinate of load node2! (dm) 182.88
Please specify the Y-coordinate of load node2! (dm) 0
For load node 1 please specify the Xresultant of the load! (N) 0
For load node 1 please specify the Yresultant of the load! (N) 445374
For load node 2 please specify the Xresultant of the load! (N) 0
For load node 2 please specify the Yresultant of the load! (N) 445374
Please select method for topology optimization! (Press g for ground structure method, r for reduced method) g
Please specify the size of the initial population (150-1000 recomended)! 850
Make sure you have the CALFEM toolbox in the same directory. CALFEM toolbox
I tried it and it should work now.
Hikaru
Hikaru 2014년 8월 11일
Try typing this in your command window
help coordxtr
If it says 'coordxtr not found' then it means that you don't have the functions in your MATLAB path. The function coordtxr and a few other functions called in the m-files are included in the CALFEM toolbox (see link in my previous comment). You need those to run the program.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by