Optimization: Code generation and execution

Mandatory element


The code generation has the same task in the simulation: it shall provide the code for an optimization, which can then be solved in an appropriate optimization environment.

Explanation of the editor

Code generation

The code generation works in the same way as in the simulation. The preferred language specification can be chosen from a list of predefined specifications or you can choose a user-defined language specification. Additional information on the number of degrees of freedom and other quantities is provided in the status window (Figure 1). The generated code can be copied to a file of the required file type.

Figure 1: Code generation for an optimization.

NEOS server

If you have no access to optimization software, you can also try to solve the optimization problem via the NEOS server (Figure 2). To this end, you must first of all accept the terms of condition. Afterwards, you can select the preferred solver (tab “Submit”) by selecting the type of the optimization problem at hand. After clicking on “Generate Code & Submit”, you can find the log of the solution in the history tab. Note that the NEOS server has a queue, so that it may take a couple of minutes until your problem is solved.

Figure 2: Code generation and solution on NEOS server.