Kursawe Functions—Integration of ASCII, Python, MATLAB, and Excel

This tutorial allows you to solve the Kursawe function using ASCII, Python, MATLAB, and Excel in optiSLang.

Task Description

This tutorial demonstrates how to do the following:

  • Calculate the first Kursawe function using Python

  • Calculate the first part of the second Kursawe function using MATLAB

  • Calculate the second part of the second Kursawe function using ASCII

  • Combine all functions using Excel

Preparation

Before you start the tutorial, download the kursawe_integrations zip file from here , and extract it to your working directory.

Tutorial Steps

Creating a New Project

  1. Start optiSLang.

  2. Create a new guided project.

  3. From the solver list, click Python.

Selecting the Python Input File

  1. In the Select input file dialog box, browse to the kursawe_integrations folder and select kursawe1.py.

  2. Click Open.

Selecting the Python Parameters and Response

  1. From the Detect assignments drop-down list, select Test run.

  2. In the Python 2 table, select rows x_1, x_2, and x_3 and drag them to the Parameter pane.

  3. In the Python 2 table, select row kursawe_1 and drag it to the Responses pane.

  4. Click Next.

Editing the Python Parameter Properties

  1. To highlight all of the parameters in the table, do one of the following:

    • Click the name of the first parameter, press Shift, and then click the name of the parameter the last row.

    • Click the name of the first parameter, then with the mouse key pressed, pull down to the last parameter and release the mouse key.

  2. While pressing the Shift key, double-click the range numbers in row 3.

  3. Change the lower bound to -5 and the upper bound to 5.

  4. Press Enter.

    The range of all of the parameters changes to -5 and 5.

  5. Click Next.

Defining the Python Optimization Criteria

  1. Do not adjust or add to the currently displayed values for parameters, responses, and criteria.

  2. Click Next.

Completing the Python Solver Wizard

  1. Leave the Create a template from solver chain check box clear. You will create a solver chain template in a later step.

  2. Click Finish.

  3. The solver chain is displayed in the Scenery pane.

Saving the Project

  1. To save the project, click  .

  2. Browse to the location to save the project and type a project name in the File name field.

  3. Click Save.

Starting the MATLAB Solver Wizard

  1. From the Wizards pane, drag the Solver wizard to the kursawe1 system and let it drop.

  2. From the solver list, click MATLAB.

Selecting the MATLAB Input File

  1. In the Select input file dialog box, browse to the kursawe_integrations folder and select kursawe2_1.m.

  2. Click Open.

Selecting the MATLAB Parameters and Response

  1. From the Detect assignments drop-down list, select Test run.

  2. In the MATLAB table, select rows x_1, x_2, and x_3 and drag them to the Parameter pane.

  3. In the MATLAB table, select row kursawe_2_1 and drag it to the Responses pane.

  4. Click Next.

Completing the MATLAB Solver Wizard

  1. Do not adjust the current parameter properties.

  2. Click Next.

  3. Do not adjust or add to the currently displayed values for parameters, responses, and criteria.

  4. Click Next.

  5. Leave the Create a template from solver chain check box clear. You will create a solver chain template in a later step.

  6. Click Finish.

  7. The extended solver chain is displayed in the Scenery pane.

  8. To save the project, click  .

Starting the ASCII Solver Wizard

  1. From the Wizards pane, drag the Solver wizard to the kursawe1 system and let it drop.

  2. From the solver list, click Common text based.

Selecting the ASCII Input File

  1. In the Select input file dialog box, browse to the kursawe_integrations folder and select kursawe2_2.s.

  2. Click Open.

Defining the ASCII Input Parameters

  1. Select the Copy Mode check box.

  2. In the text editor, highlight the value of x_1 (0.00000000).

  3. In the Name list, select x_1.

  4. To register the parameter, click Add.

  5. Repeat this procedure for parameters x_2 and x_3.

  6. Click Next.

  7. Do not adjust the current parameter properties.

  8. Click Next.

Selecting the ASCII Output File

  1. In the Select output file dialog box, browse to the kursawe_integrations folder and select kursawe2_2.txt.

  2. Click Open.

Selecting the ASCII Output Slot Value

  1. From the File format list, ensure Plain text file is selected and click OK.

  2. In the text editor, highlight the value in row 6 (0.00000000)

  3. Click the arrow next to Use as response and select Use as output slot from the menu.

    The value is displayed in the Output slots pane.

  4. Click Next.

Defining the ASCII Optimization Criteria

  1. Do not adjust or add to the currently displayed values for parameters, responses, and criteria.

  2. Click Next.

Importing the ASCII Solver Call File

  1. To the right of the Absolute path field, click the orange folder.

  2. Browse to the kursawe_integrations folder and select kursawe.bat.

  3. Click Open.

  4. Click Import.

  5. Click Next.

Completing the ASCII Solver Wizard

  1. Leave the Create a template from solver chain check box clear. You will create a solver chain template in a later step.

  2. Click Finish.

  3. The extended solver chain is displayed in the Scenery pane.

  4. To save the project, click  .

Completing the Excel Integration

  1. Under Modules, expand Process chain elements and Integrations.

  2. Drag the Excel integration node onto the output of the MATLAB solver output and let it drop.

  3. From the menu bar, select View > Slot flyout view mode > Full.

  4. Hover over the right side of the kursawe_2_1 node.

  5. Click kursawe_2_1 and drag it onto New slot on the left side of the Excel node.

  6. Hover over the right side of the kursawe_2_2 node.

  7. Click kursawe_2_2 and drag it onto New slot on the left side of the Excel node.

  8. Double-click the Excel node.

  9. To the right of the Absolute path field, click the orange folder.

  10. Browse to the kursawe_integrations folder and select kursawe2_combine.xls.

  11. Click Open.

  12. Switch to the Spreadsheet tab.

  13. Drag the kursawe_2_1 input slot onto the B1 cell.

  14. Drag the kursawe_2_2 input slot onto the B2 cell.

  15. Highlight cells A5 and B5 and drag them to the Responses pane.

  16. To close the dialog box, click OK.

Creating the Solver Chain Template

  1. To save the project, click  .

  2. To run the project, click  .

  3. Right-click the kursawe1 system and select Create > Create template from system from the context menu.

  4. Select the Templates folder and click OK.