## Best Practices for Open-Equation Modeling

Efficient mathematical modeling for optimization involves formulating a mathematical problem in such a way that a computer can quickly solve it. This typically involves defining the problem in terms of variables, constraints, and objectives, and then using a mathematical optimization method to find an optimal solution. Examples of mathematical optimization methods include linear programming, nonlinear programming, integer programming, and genetic algorithms.

Mathematical modeling often constitutes most of the effort on an optimization project. There is some art in the way a programmer poses the equations 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.

#### Tips for Improved Convergence

1. Rearrange to equation in residual form to:
1. Avoid divide by zero
2. Minimize use of functions like sqrt, log, exp, etc.
3. Have continuous first and second derivatives
4. Fit the equation into a linear or quadratic form
2. Bounds
1. Include variable bounds to exclude infeasible solutions
2. Variable bounds to avoid regions of strong nonlinearity
3. Caution: watch for infeasible solutions
3. Scaling:
1. Scale absolute value of variables to 1e-3 to 1e3
2. Scale absolute value of equation residuals to 1e-3 to 1e3
3. Better that 1st derivative values are closer to 1.0
4. Good initial conditions:
1. Starting near a solution can improve convergence
2. Try multiple initial conditions to verify global solution (non-convex problems)
3. Explicitly calculate intermediate values
5. 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.