running a project using genetic algorithm
1 view (last 30 days)
Show older comments
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 Comments
Hikaru
on 6 Aug 2014
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
on 7 Aug 2014
Edited: Hikaru
on 7 Aug 2014
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.
Accepted Answer
Hikaru
on 7 Aug 2014
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 Comments
Hikaru
on 11 Aug 2014
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
I tried it and it should work now.
Hikaru
on 11 Aug 2014
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.
More Answers (0)
See Also
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!