This tutorial introduces the use of indices in function applications.

### Model description

The following example will solve the following equation system:

As in the previous example, a function shall be used to calculate . This function has the same formula as before:

### Workflow

#### Notation of equation system

For the notation of the equation, we need to set up all base names of symbols that appear in the equations, i.e.

- , parameter
- , parameter
- , parameter
- , parameter
- , additional value s (new)
- , iteration variable
- , iteration variable

As indices are now involved, we also need to define the index :

- , index of 1..N (new)

The resulting notation has ID 182662.

#### Equations

Next, we can define the equations of the model. Therefore, we open the equation editor, load the notation we just created, and enter the equations as stated above in the model description. The formulated equations are available with the IDs 182663 and 182664.

#### Notation and definition of function

Because we use exactly the same function, we do not have to define and save a notation and the function itself again, but we will simply re-use this function and apply it on our new variables. The function is available with ID 182656.

#### Equation system

We are now able to construct our new equation system based on the new equations and the function saved in the previous example:

- Go to “Equation System” and load the notation
**for the equations** - Add the two equations to your system in the Connected Elements tab
- Go to the Functions tab. To use the general function created above, it must be added to the equation system and applied on the variables within this problem. In this context, applying means specifying which variable names in the equation system are supposed to be the corresponding input and output variables of the function.
- Click on “Add Function” at the bottom of the screen and open your function in the opening popup window. After loading the function, you should see the expression for as a function of the inputs and . On the left hand side of the dialog, you see the Output Naming and the Input Naming as defined in the function.
- On the right hand side of the dialog there is a section called Applications (Function Calls), which contains the tables Output Variable, Input Variables, and Parameters. Click on “Add Application”, which opens another popup window.
- In this dialog, double click into the field Applied Naming or click on “Edit Output” below that field. This opens another dialog where you can enter the naming of the output variable in the equation system.
- Enter into the Tex Expression, render, and confirm
- Double click into the table row of the variable naming
*o*or select this row and click “Edit Input”. Again a dialog is shown in which a variable naming can be entered. Enter , render, and confirm; then repeat this step for with being the applied input - Confirm these matches at the bottom of the window. When clicking on ‘A’ in the Applications, you should now find the match of the inputs (, )
- Confirm in this window at the bottom and save your equation system

This equation system is available with ID 182665.

#### Evaluation / Simulation

Your model is now complete and you can move on to the “Simulation” section of MOSAICmodeling.

- Enter a suitable description
- Select the tab Equation System and load the system created in the previous steps. Go to Indexing and set to 2
- If you now go to the tab Instantiated System and then to the Functions tab, you will notice that you still have one application but two usages, because the function is applied on all instances of , i.e., for and
- Select the tab Specifications. In the list ALL VARIABLES, you will find the variables as defined in your model notation. Therein, will be of type “CALCULATED_VALUE” because it is determined by a function
- Classify the variables and as design variables by selecting this category from the dropdown menu in the Type column. You can also assign the variables and as “ITERATION_VALUE”

### Initialization and results

This example is solved with the initial guesses for the variables and given in Table 1. After having assigned the initial guesses and the parameter values, you can save the variable specification and then the simulation. This simulation is available with ID 182666 with variable specification 182667. The solution for all iteration variables is also given in Table 1.

Name | Description | Value / Initial guess | Solution |
---|---|---|---|

Parameter | 1.0 | ||

Parameter | 1.5 | ||

Parameter | 3.0 | ||

Parameter | 3.5 | ||

Explicitly calculable value | 2.0 | ||

Explicitly calculable value | 2.5 | ||

Iteration variable | 0.0 | 2.0 | |

Iteration variable | 0.0 | 2.5 | |

Iteration variable | 0.0 | 4.0 | |

Iteration variable | 0.0 | 5.0 |