Dippy is an interface between DIP and PuLP.
Dippy allows you to express your IP model using PuLP’s modelling syntax, and write functions to customize how the IP is solved using Python.
Dippy requires that both PuLP and DIP be installed. See Build and Installation instructions for information.
The following example shows a basic Dippy script:
import coinor.pulp as pulp
import coinor.dippy as dippy
prob = dippy.DipProblem("Knapsack problem", pulp.LpMinimize)
Items = ['Hammer', 'Torch', 'Radio', 'Tent']
Weights = {'Hammer': 4, 'Torch': 1, 'Radio': 4, 'Tent': 8}
Value = {'Hammer': -2, 'Torch': -2, 'Radio': -4, 'Tent': -10}
Capacity = 15
item_vars = pulp.LpVariable.dicts("TakeItem", Items, 0, 1, pulp.LpBinary)
# objective
prob += pulp.lpSum(item_vars[item] * Value[item] for item in Items), "TotalValue"
# capacity constraint
prob += pulp.lpSum(item_vars[item] * Weights[item] for item in Items) <= Capacity, "Capacity"
dippy.Solve(prob)
print prob.objective.value()
-16.0
There are a number of differences from a standard PuLP script:
dippy.Solve() takes an optional second argument, which is a dictionary of parameters to pass directly to the DIP framework.
DIP parameters are divided into sections and names, so a nested dictionary structure is used. However, as the most common parameters appear in the ‘DECOMP’ section, parameters which are not within a section are assumed to be ‘DECOMP’ parameters. Thus, the following two statements are equivalent:
dippy.Solve(prob, {
'DECOMP': {
'CutCGL': 0,
'LogLevel': 10,
'LogDebugLevel':10,
},
'PRICE_AND_CUT': {
'LogDumpModel': 10,
},
})
dippy.Solve(prob, {
'CutCGL': '0',
'LogLevel': '10',
'LogDebugLevel':'10',
'PRICE_AND_CUT': {
'LogDumpModel': '10',
},
})
A list of parameters can be found by viewing the DIP source code in the file Dip/src/DecompParam.h. Note that all parameter values must be strings or numbers - True or False are never valid values. Some useful parameters for debugging are LogLevel, LogDebugLevel, LogDebugModel and SolveRelaxAsIp.
An important parameter (which is introduced by Dippy) is the Algorithm parameter, which determines which Dip algorithm will be used. Valid values are currently CUT (default) and PRICE_AND_CUT.
The best guide to getting started with Dippy is
Dippy – a simplified interface for advanced mixed-integer programming
Michael O?Sullivan, Qi-Shan Lim, CameronWalker, Iain Dunning, Stuart Mitchell
Report 685, University of Auckland Faculty of Engineering, Auckland, New Zealand, February 2011
http://www.optimization-online.org/DB_HTML/2011/02/2921.html