Preview

Matlab Gatool

Good Essays
Open Document
Open Document
482 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Matlab Gatool
Using Matlab to Execute a Genetic Algorithm
Optimization of Two Variable Function

The function to be optimized is given by:

[pic]

The maximum value of this two variable function is desired, however Matlab’s gatool finds the minimum of fitness functions and so as in the previous example the function must be altered as follows:

[pic]

Now we must enter this function, as before, into a Matlab function file.

Start Matlab and change the working directory to your Knowledge Based Systems folder. (i.e. U:\Current Class\KBS\) Create an m-file by either typing “edit fitness2” at the command prompt, or clicking the new file icon on the toolbar. The Matlab Genetic Algorithm accepts multiple variable functions, however these variables must be contained in an array. Therefore every “x” in the above equation is replaced with “x(1)” and every “y” with “x(2)”. Once the m-file editor is open, enter the following code:

function y = fitness2(x) y = -((1-x(1))^2*exp(-x(1)^2-(x(2)+1)^2) - (x(1) - x(1)^3 - x(2)^3)*exp(-x(1)^2-x(2)^2)); end

Save the file. (Note: The file must be saved under the same name as the function name. i.e. fitness2 as shown above)

In the Matlab command window type “gatool”. This will open the genetic algorithm tool as shown in Figure 1.

[pic]

Enter the name of your fitness function in the Fitness function text box preceded with an @ symbol as shown in Figure 1. Enter 2 for the number of variables and select Best fitness as the plot option.

Run the solver with all the default settings and observe results similar to Figure 2.

[pic]

The optimum value of x can be seen after the simulation in the gatool window in the Final point field. Record this number

Next modify the number of generations in the “Stopping Criteria” drop box. Change the number of generations to 25 and re-run the solution. Your results should resemble those of Figure 3.

[pic]

It should be noted that the Matlab Genetic

You May Also Find These Documents Helpful

  • Good Essays

    Click on the fly lab button. After reading through the lab and understanding what you will be doing, click on start lab.…

    • 862 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    This lab requires you to focus on variable assignment and calculations. Read the following program prior to completing the lab.…

    • 777 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Week 4 iLab

    • 423 Words
    • 2 Pages

    Use to capture a copy of the Simulation Execution dialog shown below and paste it into your lab document.…

    • 423 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    b. The value of the optimal solution to the revised problem is 8(2.5) + 12(2.5) = 50.…

    • 730 Words
    • 11 Pages
    Good Essays
  • Good Essays

    In cell C9, enter 1 as the # of Positions; in D9, enter Management as the Type.…

    • 566 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Bio100 Appendix G

    • 1069 Words
    • 5 Pages

    Curve: generates a best-fit curve based on the data points selected. You will be generating a best-fit curve by following the steps listed next.…

    • 1069 Words
    • 5 Pages
    Powerful Essays
  • Good Essays

    a. Using solver to solve the embedded model in the Excel sheet or by trying different values for h the optimum value will be obtained as “h=4”…

    • 956 Words
    • 4 Pages
    Good Essays
  • Good Essays

    Net360 Instructions

    • 2615 Words
    • 11 Pages

    1. We now are ready to configure the simulation. Select the Configuration/Run [pic] tab from the tool bar.…

    • 2615 Words
    • 11 Pages
    Good Essays
  • Good Essays

    Evolution Lab

    • 605 Words
    • 3 Pages

    Data: copy any data, graphs, charts, or notes that you have saved in your EvolutionLab online notebook into this section.…

    • 605 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    Punnet Square Lab

    • 393 Words
    • 2 Pages

    Well for one once you have the phenotypes all done on your Punnet Square then you go through and see what ratio of the offspring got the traits of the parents. For mine were to create phenotypes with 50% from each so my ratios were 2:4.…

    • 393 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Week 6 Lab

    • 313 Words
    • 2 Pages

    * Use <Alt><PrtSc> to capture a copy of the Simulation Execution dialog shown below and paste it into your lab document.…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Acc 403

    • 5361 Words
    • 22 Pages

    | Note: Instructions for using the software can be found in the Appendix of the textbook. |…

    • 5361 Words
    • 22 Pages
    Powerful Essays
  • Good Essays

    1. For what purpose would Gawain poet place King Arthur in line with the founders of the ancient civilizations? The purpose is to show how well respected king Arthur was, how he was known as the greatest king in medieval times, to show how he was an important leader of medieval times and Britain.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Better Essays

    5. Click the SAVE button in the upper right corner of the data window to save the data to the Lab Book.…

    • 1264 Words
    • 5 Pages
    Better Essays
  • Good Essays

    Protac

    • 827 Words
    • 4 Pages

    Veremos ahora la utilización de Solver para resolver casos de Programación Lineal, aplicándolas a un ejemplo muy elemental, tomado del libro de Eppen, Gould y Schmidt, Investigación de Operaciones en la Ciencia Administrativa, 3ra edición, Editorial Prentice Hall. En éste y en otros libros de Investigación Operativa, se encontrarán numerosas aplicaciones de Programación Lineal y no Lineal. Nota Las inestabilidades (por malas soluciones iniciales) del algoritmo de optimización no lineal no se presentan en casos de Programación Lineal, dado que Solver utiliza el Método Simplex. El Modelo de la Protrac • La Protrac Inc., fabrica dos tipos de productos químicos, E y F, cuya utilidad neta es de $5000 y $4000 por tonelada respectivamente. • Ambos pasan por operaciones de 2 departamentos de producción, que tienen una disponibilidad limitada. • El departamento A dispone de 150 horas mensuales; cada tonelada de E utiliza 10 horas de este departamento, y cada tonelada de F, 15 horas. • El departamento B tiene una disponibilidad de 160 horas mensuales. Cada tonelada de E precisa de 20 horas, y cada tonelada de F precisa de 10 horas para su producción. • Para la producción global de E y F, se deberán utilizar al menos 135 horas de verificación en el próximo mes; el producto E precisa de 30 horas y F de 10 horas de verificación por tonelada. • La alta gerencia ha decretado que es necesario producir al menos una tonelada de F por cada 3 de…

    • 827 Words
    • 4 Pages
    Good Essays