Python code for solving mathematical programming problems