Optimization

I provide 10 optimization Python modules that you can use to learn about optimization and/or to learn some Python symbolic programming (using Sympy).  The modules are presented in two groups:  Optimization Theory and Optimization Algorithms.

On the Optimization Theory sub-page, I implement optimization theory for the constrained maximization problem with one equality constraint:  max F subject to G=c where F is the objective function to be maximized, G is the constraint function, and c is the constraint constant.  I provide Python implementations of the tangency condition, Lagrange method, and for quasiconcavity and quasiconvexity conditions.

On the Optimization Algorithms sub-page, I provide Python implementations for the Steepest Descent and Newton algorithms and examples of using the Python optimization packages in Scipy and GEKKO Python.   Since problems with more than two variables and two constraints can be difficult or impossible to solve analytically, it is important to learn how to use computational optimization packages and to understand the computational algorithms used by these packages.  

 

Python

 

Python combines clear and easy-to-use programming language with a large number of packages for different purposes.  I use these six packages, and you must install them in your Python environment:

 

Sympy (“Symbolic Python”) provides “symbolic” programming similar to Maple.  This is also called “computer algebra” that you can use for manipulation of mathematical expressions, differentiation, and solution of systems of equations.

 

Numpy (“Numeric Python”) is the fundamental package for numerical computation and, like Matlab, it focuses on array and matrix operations.  Among other tasks, I use Numpy for matrix operations.

 

Matplotlib provides the plotting functionality that is contained in Matlab.  I use it for 3-dimensional plots of objective and constraint functions and for 2-dimensional plots of level curves.

 

Math contains the numerous common mathematical functions, but I need only the square root function.

 

Scipy (“Scientific Python”) provides a wide variety of numerical algorithms, similar to the “toolboxes” in Matlab.  I use the optimization toolbox, but there many others. 

GEKKO provides an interface to sophisticated optimization algorithms.