|
| Using NumPy arrays to create variables: Using NumPy arrays
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Use NumPy arrays for creating a 3-dimensional array of variables, then use it to create a model. |
| File(s): |
example_array.py |
|
|
| Visualize the BB tree: Using the newnode callback
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Shows how to visualize the BB tree of a problem after (partially) solving it. |
| File(s): |
example_bbtree.py |
|
|
| Irreducible Infeasible Sets: Using Irreducible Infeasible Sets
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Shows how to analyze an infeasible problem by retrieving an irreducible infeasible subset |
| File(s): |
example_infeasible.py |
|
|
| Loading a problem: Loading a problem directly
|
| |
|
| Modeling with user functions: Modeling with user functions
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Shows how to create and solve a nonlinear problem whose constraints and objective functions are defined as user functions |
| File(s): |
example_userfunc.py |
|
|
| Using Python model objects to build a problem: Modelling using Python objects
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Demonstrate how variables, or arrays thereof, and constraints, or arrays of constraints, can be added into a problem. Prints
the solution and all attributes/controls of the problem.
|
| File(s): |
example_modeling.py |
|
|
| Using Python model objects to build a problem: Modelling using Python objects
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Using the compact xpress.problem() declaration to add variables, constraints and objective in one instruction. |
| File(s): |
example_modeling2.py |
|
|
| Changing the optimization problem: Changes to a problem
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Changing an optimization problem using the Xpress Python interface. |
| File(s): |
small_change.py |
|
|
| Extending a problem: Extending a problem
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Construct a problem using addVariable and addConstraint, then use the Xpress API routines to amend the problem with rows and
quadratic terms.
|
| File(s): |
example_modify.py |
|
|
| Using NumPy and Xpress: Using NumPy and Xpress
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
An example of printing a matrix of random numbers and a problem formulation that uses the xpress.Dot() operator to formulate
constraints simply.
Note that the NumPy dot operator is not suitable here as the result is an expression in the Xpress variables.
|
| File(s): |
example_numpy1.py, example_numpy2.py |
|
|
| Finding an LP subsystem with as many constraints as possible:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Given an infeasible LP, find the feasible subsystem of constraints of maximum cardinality. |
| File(s): |
example_phase1.py |
|
|
| Solving a quadratically constrained problem: Building quadratic expressions
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Solve a quadratically constrained problem |
| File(s): |
example_qcqp.py |
|
|
| Solving a nonconvex quadratic problem: Building quadratic expressions
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Solve a nonconvex quadratic problem |
| File(s): |
example_quadnonconvex.py |
|
|
| Solving a quadratically problem: Building quadratic expressions
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Solve a quadratic problem |
| File(s): |
example_quadratic.py |
|
|
| Repeatedly solving a problem: Solving a problem multiple times
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Reads a problem, solves it, then adds a constraint and re-solves it |
| File(s): |
example_resolve.py |
|
|
| Using indicators: Model with indicators
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Construct a problem from scratch with variables of various types. Adds indicator constraints, Special Ordered Sets (SOSs),
and
shows how to retrieve such data once it has been added to the problem using the API functions
|
| File(s): |
example_SOS_indicators.py |
|
|
| The travelling salesman problem: Using Xpress callbacks
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Retrieves an example fromn http://www.math.uwaterloo.ca/tsp/world/countries.html
and creates a corresponding TSP instance, then solves it using the Xpress Optimizer
library with the appropriate callback. Once the optimization is over
(i.e. the time limit is reached or we find an optimal solution) the
optimal tour is displayed using matplotlib.
|
| File(s): |
example_tsp.py |
|
|
| Solving a TSP using NumPy: Using Xpress callbacks
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
A randomly generated TSP problem is modeled using
NumPy vectors and matrices and solved using the Optimizer's
libraries and callback functions.
|
| File(s): |
example_tsp_numpy.py |
|
|
| Writing and reading problem files: Writing and reading a problem to disk
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a few variables, then build a problem and save it to a file.
Re-read that file into a new problem and solve it
|
| File(s): |
example_write_read.py |
|
|
| The feasiblity pump: Writing and reading a problem to disk
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Feasibility pump (prototype) using the Xpress Python interface. |
| File(s): |
feas_pump.py |
|
|
| Knapsack problem: MIP problem with binary variables
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Example of a knapsack problem formulated with the Xpress Python interface. |
| File(s): |
knapsack.py |
|
|
| The n-queens problem: Puzzle modeling
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
The n queens: place n queens on an nxn chessboard so that none of them can be eaten in one move. |
| File(s): |
n_queens.py |
|
|
| Min-cost-flow problem : Modelling a graph problem
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
solving a min-cost-flow problem using the Xpress Python interface. |
| File(s): |
netflow.py |
|
|
| Solving Sudoku: Puzzle modeling
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Place numbers from 1 to 9 into a 9x9 grid such that no number repeats in any row, in any column, and in any 3x3 sub-grid. |
| File(s): |
sudoku.py |
|
|
| Comparing Matrices: Compare two optimization problems
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Load the coefficient matrices of two optimization problems saved in MPS or LP format using the Xpress Optimizer libraries
and compare each line by line using SciPy's matrix routines.
|
| File(s): |
compare_matrices.py |
|
|
| Multicommodity flow problem: Solve a multicommodity flow minimum cost optimization problem on a randomly created graph
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a random directed graph using NumPy's random functions and then model and solve a minimum-cost multicommodity flow
problem constructed on that graph.
|
| File(s): |
example_multicommodity_flow.py |
|
|
| Find largest-area inscribed polygon:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Given n, find the n-sided polygon of largest area inscribed in the unit circle. |
| File(s): |
polygon.py |
|
|
| Read problem data into matrix and vectors:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Obtain coefficient matrix, objective coefficients, and constraints' right-hand sides for a given problem. |
| File(s): |
example_getmatrix.py |
|
|
| Solve a nonconvex MIQCQP problem:
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Reformulate a MIQCQP into a MILP and add callbacks to enforce quadratic feasibility of the nonconvex constraints. |
| File(s): |
miqcqp_solver.py |
|
|
| Solve a simple MIP using Benders decomposition:
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Solve a simple MIP using Benders decomposition. Courtesy of Georgios Patsakis (UC Berkeley, Amazon) and Richard L.-Y. Chen
(Amazon).
|
| File(s): |
benders_decomp.py |
|
|
| Create a problem with piecewise linear functions:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a simple problem using the modelling construct xpress.pwl for creating piecewise linear functions.
|
| File(s): |
piecewise_linear.py |
|
|
| Use the API to create a model with piecewise linear functions:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a simple problem using the API function problem.addpwlcons to create piecewise linear functions. The resulting model is equivalent to piecewise_linear.py.
|
| File(s): |
piecewise_linear2.py |
|
|
| Create a problem with general constraints that use operator abs:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a simple problem using the modelling methods abs for creating general constraints.
|
| File(s): |
general_constraints_abs.py |
|
|
| Create a problem with general constraints with the operator abs by using the API:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a simple problem using the API function problem.addgencons for creating general constraints.
|
| File(s): |
general_constraints_abs_api.py |
|
|
| Create a problem with general constraints that use operator max:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a simple problem using the modelling methods max for creating general constraints.
|
| File(s): |
general_constraints_max.py |
|
|
| Create a problem with general constraints with operator max by using the API:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a simple problem using the API function problem.addgencons for creating max general constraints.
|
| File(s): |
general_constraints_max_api.py |
|
|
| Create a problem with logical constraints:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a simple problem using the modelling methods max for creating general constraints.
|
| File(s): |
general_constraints_logic.py |
|
|
| Create a problem with general constraints with logic operators by using the API:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Create a simple problem using the API function problem.addgencons for creating logical (AND and OR) general constraints.
|
| File(s): |
general_constraints_logic_api.py |
|
|
| Create an iterative algorithm cutting stock problem:
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
Use the modeling features to create an iterative solver for a cutting stock problem. |
| File(s): |
cuttingstock.py |
|
|
| Maximize the sum of logistic curves subject to linear and piecewise linear constraints:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Approximate the logistic curves using piecewise linear functions. |
| File(s): |
maxSumLogistic.py |
|
|
| Transportation problem with piecewise-linear costs:
|
| |
|
| Type: |
Programming |
| Rating: |
2 (easy-medium) |
| Description: |
Model a transportation problem where the cost are modeled using the xpress.problem.addpwlcons function.
|
| File(s): |
pwl_transp.py |
|
|
| Modeling Satisfiability (SAT) problems with MIP:
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
A rudimentary SAT solver that translates a Satisfiability (SAT) problem into a MIP and solves it. |
| File(s): |
example_gencons_sat.py |
|
|
| Modeling PseudoBoolean Optimization problems with MIP:
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
A solver of PseudoBoolean optimization problems (PBO) that translates a problem into a MIP and solves it. |
| File(s): |
example_gencons_pbo.py |
|
|