PySCIPOpt
Python Interface to the SCIP Optimization Suite
piecewise.py File Reference

several approaches for solving problems with piecewise linear functions. More...

Go to the source code of this file.

Functions

def mult_selection (model, a, b)
 
def convex_comb_sos (model, a, b)
 
def convex_comb_dis (model, a, b)
 
def gray (i)
 
def convex_comb_dis_log (model, a, b)
 
def convex_comb_agg (model, a, b)
 
def convex_comb_agg_log (model, a, b)
 

Variables

list a = [ -10, 10, 15, 25, 30, 35, 40, 45, 50, 55, 60, 70]
 
list b = [ -20,-20, 15, -21, 0, 50, 18, 0, 15, 24, 10, 15]
 
 model = Model("multiple selection")
 
 X
 
 Y
 
 z
 
 u = model.addVar(vtype="C", name="u")
 
 A = model.addCons(3*X + 4*Y <= 250, "A")
 
 B = model.addCons(7*X - 2*Y + 3*u == 170, "B")
 
 w
 

Detailed Description

several approaches for solving problems with piecewise linear functions.

Definition in file piecewise.py.

Function Documentation

def piecewise.convex_comb_agg (   model,
  a,
  b 
)
convex_comb_agg -- add piecewise relation convex combination formulation -- non-disaggregated.
Parameters:
    - model: a model where to include the piecewise linear relation
    - a[k]: x-coordinate of the k-th point in the piecewise linear relation
    - b[k]: y-coordinate of the k-th point in the piecewise linear relation
Returns the model with the piecewise linear relation on added variables X, Y, and z.

Definition at line 149 of file piecewise.py.

def piecewise.convex_comb_agg_log (   model,
  a,
  b 
)
convex_comb_agg_log -- add piecewise relation with a logarithmic number of binary variables
using the convex combination formulation -- non-disaggregated.
Parameters:
    - model: a model where to include the piecewise linear relation
    - a[k]: x-coordinate of the k-th point in the piecewise linear relation
    - b[k]: y-coordinate of the k-th point in the piecewise linear relation
Returns the model with the piecewise linear relation on added variables X, Y, and z.

Definition at line 178 of file piecewise.py.

def piecewise.convex_comb_dis (   model,
  a,
  b 
)
convex_comb_dis -- add piecewise relation with convex combination formulation
Parameters:
    - model: a model where to include the piecewise linear relation
    - a[k]: x-coordinate of the k-th point in the piecewise linear relation
    - b[k]: y-coordinate of the k-th point in the piecewise linear relation
Returns the model with the piecewise linear relation on added variables X, Y, and z.

Definition at line 73 of file piecewise.py.

def piecewise.convex_comb_dis_log (   model,
  a,
  b 
)
convex_comb_dis_log -- add piecewise relation with a logarithmic number of binary variables
using the convex combination formulation.
Parameters:
    - model: a model where to include the piecewise linear relation
    - a[k]: x-coordinate of the k-th point in the piecewise linear relation
    - b[k]: y-coordinate of the k-th point in the piecewise linear relation
Returns the model with the piecewise linear relation on added variables X, Y, and z.

Definition at line 105 of file piecewise.py.

def piecewise.convex_comb_sos (   model,
  a,
  b 
)
convex_comb_sos -- add piecewise relation with gurobi's SOS constraints
Parameters:
    - model: a model where to include the piecewise linear relation
    - a[k]: x-coordinate of the k-th point in the piecewise linear relation
    - b[k]: y-coordinate of the k-th point in the piecewise linear relation
Returns the model with the piecewise linear relation on added variables X, Y, and z.

Definition at line 49 of file piecewise.py.

def piecewise.gray (   i)
returns i^int(i/2)

Definition at line 100 of file piecewise.py.

def piecewise.mult_selection (   model,
  a,
  b 
)
mult_selection -- add piecewise relation with multiple selection formulation
Parameters:
    - model: a model where to include the piecewise linear relation
    - a[k]: x-coordinate of the k-th point in the piecewise linear relation
    - b[k]: y-coordinate of the k-th point in the piecewise linear relation
Returns the model with the piecewise linear relation on added variables X, Y, and z.

Definition at line 18 of file piecewise.py.