## Best Practices for Open-Equation Modeling

#### Modeling Exercise

Modeling often constitutes most of the effort on an optimization project. There is some art in the way a programmer poses the model in a way that allows solvers to efficiently find a solution. Below are some tips and an exercise on ways to rearrange the model equations for improved convergence.

Worksheet with Modeling Exercises

#### Tips for Improved Convergence

- Rearrange to equation in residual form to:
- Avoid divide by zero
- Minimize use of functions like sqrt, log, exp, etc.
- Have continuous first and second derivatives
- Fit the equation into a linear or quadratic form

- Bounds
- Include variable bounds to exclude infeasible solutions
- Variable bounds to avoid regions of strong nonlinearity
- Caution: watch for infeasible solutions

- Scaling:
- Scale absolute value of variables to 1e-3 to 1e3
- Scale absolute value of equation residuals to 1e-3 to 1e3
- Better that 1st derivative values are closer to 1.0

- Good initial conditions:
- Starting near a solution can improve convergence
- Try multiple initial conditions to verify global solution (non-convex problems)
- Explicitly calculate intermediate values

- Check iteration summary for improved convergence

#### Exercise Results for the Two Bar Truss

The following models are taken from the homework assignment on the Two Bar Truss problem. The initial version is most similar to how the problem would be posed in a textbook. Removing the SQRT and adding constraints to the variables shows improvements in model convergence. Explicit definition of some of the variables adds additional improvements.