|
|
| |
Xpress Optimizer examples
Examples of using the Optimizer library
|
| Calling the library from C |
|
|
| Branching rule branching on the most violated Integer/Binary: Using the change branch callbacks
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Demonstrates the Xpress Optimizer change branch callbacks |
| File(s): |
mostviolated.c |
|
|
| Apply a binary fixing heuristic to an unpresolved MIP problem: Changing bounds, accessing solver controls
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
We take a production plan model and solve its LP relaxation.
Next we fix those binary variables that are very
near zero to 0.0, and those that are almost one to 1.0, by changing
their respective upper and lower bounds. Finally, we solve the
modified problem as a MIP.
This heuristic will speed up solution - though may fail to optimse
the problem.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
fixbv.c |
| Data file(s): |
coco.mat |
|
|
| Perform objective function parametrics on a global problem: Saving/loading bases, changing objective coefficients
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
We take a production plan model and observe how the optimal
value of the objective function changes as we vary
BEN(3), the benefit per month from finishing Project 3.
The program increments BEN(3) from 8 to 15, and for each of these
values revises the objective coefficients of the variables x(3,t),t=1:2
and finds the best integer solution. Note that, for each t, the
coefficient of x(3,t) is BEN(3)*(3-t) = BEN(3)*(6-t-4+1).
The results are displayed on screen and the problem statistics stored
in a log file.
|
| File(s): |
globjpar.c |
| Data file(s): |
pplan.mat |
|
|
| Perform RHS parametrics on a global problem: Changing RHS coefficients, working with bases
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
We take a production plan model and observe how the optimal
value of the objective function changes as we vary
the RHS element RESMAX(2), the resources available in Month 2.
The program decrements RESMAX(2) from 6 to 1, and for each of these
values assesses the feasibility of the revised problem and, where
possible, finds the best integer solution.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
glrhspar.c |
| Data file(s): |
pplan.mat |
|
|
| Apply a primal heuristic to a knapsack problem: Using the global log callback
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
3 (intermediate) |
| Description: |
The program demonstrates the use of the global log callback.
We take the knapsack problem stored in burglar.mat and instigate a
global search. At each node, so long as the current solution is
both LP optimal and integer infeasible, we truncate the solution
values to create a feasible integer solution. We then update the
cutoff, if the new objective value has improved it, and continue
the search.
|
| File(s): |
knapsack.c |
| Data file(s): |
burglar.mat |
|
|
| Apply an integer fixing heuristic to a MIP problem: Changing bounds
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mat which
seeks to optimise the operating pattern of a group of electricity
generators. We solve this MIP with a very loose integer tolerance
and then fix all binary and integer variables to their rounded
integer values, changing both their lower and upper bounds. We then
solve the resulting LP.
The results are displayed on screen and the problem statistics
stored in a logfile.
|
| File(s): |
roundint.c |
| Data file(s): |
hpw15.mat |
|
|
| Load an LP and modify it by adding an extra constraint: Load LP problem, adding a constraint
|
| |
|
| Type: |
Programming |
| Rating: |
1 (simple) |
| Description: |
The problem
Maximize
2x + y
subject to
c1: x + 4y <= 24
c2: y <= 5
c3: 3x + y <= 20
c4: x + y <= 9
and
0 <= x,y <= +infinity
and the extra constraint
c5: 6x + y <= 20
are first stored in the user's data structures. The LP is then loaded
into Optimizer, using loadprob, and solved using the primal simplex
algorithm. Next, the extra constraint is added to the problem matrix,
using addrows, and the revised problem solved using the dual algorithm.
In each case, the problem matrix is output to a file, the objective
function value displayed on screen, and the problem statistics are
are stored in a log file. |
| File(s): |
loadlp.c |
|
|
| Save/access a postsolved solution in memory: Retrieving solution values and global search information
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
We take the knapsack problem in burglar.mat and instigate a global
search. Whenever an integer solution it found it is postsolved,
stored in memory, and printed to an output file. The best and final
solution values, and other global search information, are displayed
on screen.
|
| File(s): |
savesol.c |
| Data file(s): |
burglar.mat |
|
|
| Adding MIP solutions to the Optimizer: Using the optnode callback, saving/loading bases, changing bounds
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
At each node of the global search a variable fixing heuristic is applied to a copy of the problem. If an integer solution
is found for the modified (sub)problem then this solution is added to the original problem.
|
| File(s): |
addmipsol.c |
| Data file(s): |
addmipsol.mat |
|
|
| Solve LP, displaying the initial and optimal tableau: Retrieve basic variables and their names, btran
|
| |
|
| Type: |
Programming |
| Rating: |
3 (intermediate) |
| Description: |
Inputs an MPS matrix file and required optimization sense, and
proceeds to solve the problem with lpoptimize. The simplex
algorithm is interrupted to get its intial basis, and a tableau is
requested with a call to function showtab. Once the solution is
found, a second call produces the optimal tableau.
Function showtab retrieves the pivot order of the basic variables,
along with other problem information, and then constructs (and
displays) the tableau row-by-row using the backwards transformation,
btran.
Note that tableau should only be used with matrices whose MPS names
are no longer than 8 characters.
|
| File(s): |
tableau.c |
| Data file(s): |
tablo.mat, tablobig.mat |
|
|
| Modify problem: add an extra variable within an additional constraint: Adding rows and columns, branching directives
|
| |
|
| Type: |
Cutting stock |
| Rating: |
3 (intermediate) |
| Description: |
We take the trimloss problem described in
trimloss.mat, in which each integer variable x(p) represents
the number of rolls cut to pattern p. We define a new
integer variable y=SUM(p)x(p) and add the associated
constraint
x(1)+x(2)+...+x(N)-y = 0
We do this by first adding a row containing the (unitary)
coefficients of the x(p), and then a column corresponding
to y. We output the revised matrix to a file and then solve
the revised MIP, giving y the highest branching priority.
Finally, we output the solution, both to the screen and to
an ASCII solution file. |
| File(s): |
trimloss.c |
| Data file(s): |
trimloss.mat |
|
|
| 10 best solutions with the MIP solution enumerator: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mat which seeks to
optimise the operating pattern of a group of electricity generators. We
run the MIP solution enumerator on the problem using the default setup
obtaining the best 10 solutions. The best 10 solutions are stored to a
MIP solution pool. The solutions' objectives and solution values are
printed to screen.
|
| File(s): |
mipsolenum.c |
| Data file(s): |
hpw15.mat |
|
|
| Collecting all solutions with the MIP solution pool: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mat which seeks to
optimise the operating pattern of a group of electricity generators. We
solve the problem collecting all solutions found during the MIP search.
The optimal solution's objective and solution values are printed to
screen.
|
| File(s): |
mipsolpool.c |
| Data file(s): |
hpw15.mat |
|
|
| Repairing infeasibility: Using repairinfeas
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Demonstrates the repairinfeas utility,
prints a relaxation summary and
creates the relaxed subproblem.
|
| File(s): |
repair.c |
|
|
| Goal Programming: Preemptive and Archimedian Goal Programming with objective functions or constraints
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Implementation of preemptive and Archimedian Goal Programming algorithms working on objective functions or constraints. The
Goal Programming directives are input from the configuration files *.gol.
|
| File(s): |
goal_example.c |
| Data file(s): |
goalcon3.mat.gz, goalobj1.mat.gz, ga3.gol, gb3.gol, gc1.gol, gd1.gol |
|
|
|
| Calling the library from C# |
|
|
| Apply a binary fixing heuristic to an unpresolved MIP problem: Changing bounds, accessing solver controls
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
We take a production plan model and solve its LP relaxation.
Next we fix those binary variables that are very
near zero to 0.0, and those that are almost one to 1.0, by changing
their respective upper and lower bounds. Finally, we solve the
modified problem as a MIP.
This heuristic will speed up solution - though may fail to optimse
the problem.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
FixBV.cs |
|
|
| Irreducible Infeasible Set Search: Using IIS
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Anlaysing an infeasible problem by identifying an irreducible infeasible subset (IIS)
|
| File(s): |
IISExample.cs |
| Data file(s): |
iisexample.mat |
|
|
| Apply a primal heuristic to a knapsack problem: Using the global log callback
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
3 (intermediate) |
| Description: |
The program demonstrates the use of the global log callback.
We take the knapsack problem stored in burglar.mat and instigate a
global search. At each node, so long as the current solution is
both LP optimal and integer infeasible, we truncate the solution
values to create a feasible integer solution. We then update the
cutoff, if the new objective value has improved it, and continue
the search.
|
| File(s): |
Knapsack.cs |
| Data file(s): |
burglar.mat |
|
|
| Load an LP and modify it by adding an extra constraint: Load LP problem, adding a constraint
|
| |
|
| Type: |
Programming |
| Rating: |
1 (simple) |
| Description: |
The problem
Maximize
2x + y
subject to
c1: x + 4y <= 24
c2: y <= 5
c3: 3x + y <= 20
c4: x + y <= 9
and
0 <= x,y <= +infinity
and the extra constraint
c5: 6x + y <= 20
are first stored in the user's data structures. The LP is then loaded
into Optimizer, using loadprob, and solved using the primal simplex
algorithm. Next, the extra constraint is added to the problem matrix,
using addrows, and the revised problem solved using the dual algorithm.
In each case, the problem matrix is output to a file, the objective
function value displayed on screen, and the problem statistics are
are stored in a log file. |
| File(s): |
LoadLP.cs |
|
|
| 10 best solutions with the MIP solution enumerator: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mat which seeks to
optimise the operating pattern of a group of electricity generators. We
run the MIP solution enumerator on the problem using the default setup
obtaining the best 10 solutions. The best 10 solutions are stored to a
MIP solution pool. The solutions' objectives and solution values are
printed to screen.
|
| File(s): |
MipSolEnum.cs |
| Data file(s): |
hpw15.mat |
|
|
| Collecting all solutions with the MIP solution pool: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mat which seeks to
optimise the operating pattern of a group of electricity generators. We
solve the problem collecting all solutions found during the MIP search.
The optimal solution's objective and solution values are printed to
screen.
|
| File(s): |
MipSolPool.cs |
| Data file(s): |
hpw15.mat |
|
|
| Save/access a postsolved solution in memory: Retrieving solution values and global search information
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
We take the knapsack problem in burglar.mat and instigate a global
search. Whenever an integer solution it found it is postsolved,
stored in memory, and printed to an output file. The best and final
solution values, and other global search information, are displayed
on screen.
|
| File(s): |
SaveSol.cs |
| Data file(s): |
burglar.mat |
|
|
|
| Calling the library from Java |
|
|
| Adding the message callback in Java: Using the message callback
|
| |
|
| Type: |
Adding callbacks |
| Rating: |
1 (simple) |
| Description: |
The examples demonstrates how to define a messaging callback for the Xpress Optimizer in Java. |
| File(s): |
Callback.java |
|
|
| Irreducible Infeasible Set Search: Using IIS
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Anlaysing an infeasible problem by identifying an irreducible infeasible subset (IIS)
|
| File(s): |
IISExample.java |
| Data file(s): |
iisexample.mat |
|
|
| 10 best solutions with the MIP solution enumerator: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mat which seeks to
optimise the operating pattern of a group of electricity generators. We
run the MIP solution enumerator on the problem using the default setup
obtaining the best 10 solutions. The best 10 solutions are stored to a
MIP solution pool. The solutions' objectives and solution values are
printed to screen.
|
| File(s): |
MipSolEnum.java |
| Data file(s): |
hpw15.mat |
|
|
| Collecting all solutions with the MIP solution pool: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mat which seeks to
optimise the operating pattern of a group of electricity generators. We
solve the problem collecting all solutions found during the MIP search.
The optimal solution's objective and solution values are printed to
screen.
|
| File(s): |
MipSolPool.java |
| Data file(s): |
hpw15.mat |
|
|
| Collecting all solutions with the MIP solution pool: Modify a problem by adding extra rows and columns
|
| |
|
| Type: |
Trim Loss |
| Rating: |
3 (intermediate) |
| Description: |
We take a trimloss problem in which each integer variable x(p)
represents the number of rolls cut to pattern p.
We define a new integer variable y=SUM(p)x(p) and add the associated
constraint
x(1)+x(2)+...+x(N)-y = 0
We do this by first adding a row containing the (unitary)
coefficients of the x(p), and then a column corresponding to y.
We output the revised matrix to a file and then solve the revised
MIP, giving y the highest branching priority. Finally, we output
the solution, both to the screen and to an ASCII solution file.
|
| File(s): |
Trimloss.java |
| Data file(s): |
pplan.mat |
|
|
|
| Calling the library from VB.NET |
|
|
| Apply a binary fixing heuristic to an unpresolved MIP problem: Changing bounds, accessing solver controls
|
| |
|
| Type: |
Production planning |
| Rating: |
3 (intermediate) |
| Description: |
We take a production plan model and solve its LP relaxation.
Next we fix those binary variables that are very
near zero to 0.0, and those that are almost one to 1.0, by changing
their respective upper and lower bounds. Finally, we solve the
modified problem as a MIP.
This heuristic will speed up solution - though may fail to optimse
the problem.
The results are displayed on screen and the problem statistics
stored in a log file.
|
| File(s): |
FixBV.vb |
| Data file(s): |
coco.mat |
|
|
| Irreducible Infeasible Set Search: Using IIS
|
| |
|
| Type: |
Programming |
| Rating: |
4 (medium-difficult) |
| Description: |
Anlaysing an infeasible problem by identifying an irreducible infeasible subset (IIS)
|
| File(s): |
GetBreakers.vb |
| Data file(s): |
infeas.lp |
|
|
| Apply a primal heuristic to a knapsack problem: Using the global log callback
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
3 (intermediate) |
| Description: |
The program demonstrates the use of the global log callback.
We take the knapsack problem stored in burglar.mat and instigate a
global search. At each node, so long as the current solution is
both LP optimal and integer infeasible, we truncate the solution
values to create a feasible integer solution. We then update the
cutoff, if the new objective value has improved it, and continue
the search.
|
| File(s): |
Knapsack.vb |
| Data file(s): |
burglar.mat |
|
|
| Load an LP and modify it by adding an extra constraint: Load LP problem, adding a constraint
|
| |
|
| Type: |
Programming |
| Rating: |
1 (simple) |
| Description: |
The problem
Maximize
2x + y
subject to
c1: x + 4y <= 24
c2: y <= 5
c3: 3x + y <= 20
c4: x + y <= 9
and
0 <= x,y <= +infinity
and the extra constraint
c5: 6x + y <= 20
are first stored in the user's data structures. The LP is then loaded
into Optimizer, using loadprob, and solved using the primal simplex
algorithm. Next, the extra constraint is added to the problem matrix,
using addrows, and the revised problem solved using the dual algorithm.
In each case, the problem matrix is output to a file, the objective
function value displayed on screen, and the problem statistics are
are stored in a log file. |
| File(s): |
LoadLP.vb |
|
|
| 10 best solutions with the MIP solution enumerator: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mat which seeks to
optimise the operating pattern of a group of electricity generators. We
run the MIP solution enumerator on the problem using the default setup
obtaining the best 10 solutions. The best 10 solutions are stored to a
MIP solution pool. The solutions' objectives and solution values are
printed to screen.
|
| File(s): |
MipSolEnum.vb |
| Data file(s): |
hpw15.mat |
|
|
| Collecting all solutions with the MIP solution pool: Using the solution enumerator and MIP solution pool
|
| |
|
| Type: |
Power generation |
| Rating: |
3 (intermediate) |
| Description: |
We take the power generation problem stored in hpw15.mat which seeks to
optimise the operating pattern of a group of electricity generators. We
solve the problem collecting all solutions found during the MIP search.
The optimal solution's objective and solution values are printed to
screen.
|
| File(s): |
MipSolPool.vb |
| Data file(s): |
hpw15.mat |
|
|
| Save/access a postsolved solution in memory: Retrieving solution values and global search information
|
| |
|
| Type: |
Knapsack problem |
| Rating: |
2 (easy-medium) |
| Description: |
We take the knapsack problem in burglar.mat and instigate a global
search. Whenever an integer solution it found it is postsolved,
stored in memory, and printed to an output file. The best and final
solution values, and other global search information, are displayed
on screen.
|
| File(s): |
SaveSol.vb |
| Data file(s): |
burglar.mat |
|
|
|
|
|
|