Simple Examples
Models presented below are a test suite of optimization problems. They are part of the test suite used to verify modifications to the APMonitor software. Users may also find this collection useful to compare APMonitor syntax to other modeling languages, for solver benchmarking, or as example problems in optimization. Models may be submitted through the Online Web-based Interface.
Test problem with 2 local minima
This optimization problem has 2 local minima. The two problem solutions are found at (0,0,8) with objective 936.0 (global minimum) and (7,0,0) with objective 951.0.
$$\begin{align}\mathrm{minimize} \quad & 100-x_1^2-2x_2^2-x_3^2-x_1x_2-x_1x_3 \\ \mathrm{subject\;to}\quad & 8x_1+14x_2+7x_3=56 \\ & x_1^2+x_2^2+x_3^2\geq25 \\ & x_1,x_2,x_3\ge0 \end{align}$$
- View APMonitor Solution
- Solve with Python Gekko
m = GEKKO(remote=False)
x1,x2,x3 = m.Array(m.Var,3,lb=0)
m.Minimize(1000-x1**2-2*x2**2-x3**2-x1*x2-x1*x3)
m.Equations([8*x1+14*x2+7*x3==56,
x1**2+x2**2+x3**2>=25])
m.solve(disp=False)
print(x1.value,x2.value,x3.value)
Numerical Integration
This problem demonstrates how to numerically integrate a function. In this case, the function of interest is x = 2 t with an exact solution of y = t2 .
The following Python script runs the model and plots the results:
Download integration example problem