LpProblem  
LpVariable  
LpAffineExpression  
LpConstraint  
LpConstraint.makeElasticSubProblem  
FixedElasticSubProblem 
Todo
LpFractionConstraint, FractionElasticSubProblem
Bases: object
An LP Problem
Creates an LP Problem
This function creates a new LP Problem with the specified associated parameters
Parameters: 


Returns:  An LP Problem 
Three important attributes of the problem are:
Some of the more important methods:
Solve the given Lp problem.
This function changes the problem to make it suitable for solving then calls the solver.actualSolve method to find the solution
Parameter:  solver – Optional: the specific solver to be used, defaults to the default solver. 

Rounds the lp variables
Sets the input variable as the objective function. Used in Columnwise Modelling
Parameter:  obj – the objective function of type LpConstraintVar 

Write the given Lp problem to a .lp file.
This function writes the specifications (objective function, constraints, variables) of the defined Lp problem to a file.
Parameter:  filename – the name of the file to be created. 

This class models an LP Variable with the specified associated parameters
Parameters: 


Creates a dictionary of LP variables
Parameters: 


Returns:  A dictionary of LP Variables 
Example:
>>> x = LpVariable('x',lowBound = 0, cat='Continuous')
>>> y = LpVariable('y', upBound = 5, cat='Integer')
gives , , an integer.
Bases: pulp.odict.OrderedDict
A linear combination of LpVariables. Can be initialised with the following:
Examples:
>>> f=LpAffineExpression(LpElement('x'))
>>> f
1*x + 0
>>> d = LpAffineExpression(dict(x_0=1, x_1=3, x_2=4))
>>> d
1*x_0 + 3*x_1 + 4*x_2 + 0
>>> x_name = ['x_0', 'x_1', 'x_2']
>>> x = [LpVariable(x_name[i], lowBound = 0, upBound = 10) for i in range(3) ]
>>> c = LpAffineExpression([ (x[0],1), (x[1],3), (x[2],4)])
>>> c
1*x_0 + 3*x_1 + 4*x_2 + 0
>>> c == d
1*x_0 + 3*x_1 + 4*x_2 + 1*x_0 + 3*x_1 + 4*x_2 + 0 = 0
>>> ( c == d) == LpConstraint(0)
<class 'pulp.pulp.LpConstraint'>
In brief, where (note the order):
 x[i] is an LpVariable
 a[i] is a numerical coefficient.
Calculate the sum of a list of linear expressions
Parameter:  vector – A list of linear expressions 

Bases: pulp.pulp.LpAffineExpression
An LP constraint
Parameters: 


Builds an elastic subproblem by adding variables to a hard constraint
uses FixedElasticSubProblem
A constraint (equality may be replaced by or ) can be elasticized to the form
where denotes some interval containing the value .
Define the constraint in two steps:
 instantiate constraint (subclass of LpConstraint) with target .
 call its makeElasticSubProblem() method which returns an object of type FixedElasticSubProblem (subclass of LpProblem)  its objective is the minimization of the distance of from .
constraint = LpConstraint(..., rhs = c)
elasticProblem = constraint.makeElasticSubProblem(
penalty = <penalty_value>,
proportionFreeBound = <freebound_value>,
proportionFreeBoundList = <freebound_list_value>,
)
The penalty applies to the constraint at points where . The magnitude of <penalty_value> can be assessed by examining the final objective function in the .lp file written by LpProblem.writeLP().
Example:
>>> constraint_1 = LpConstraint('ex_1',sense=1,rhs=200)
>>> elasticProblem_1 = constraint_1.makeElasticSubproblem(penalty=1, proportionFreeBound = 0.01)
>>> constraint_2 = LpConstraint('ex_2',sense=0,rhs=500)
>>> elasticProblem_2 = constraint_2.makeElasticSubproblem(penalty=1,
proportionFreeBoundList = [0.02, 0.05])
Following are the methods of the returnvalue:
Bases: pulp.pulp.LpProblem
Contains the subproblem generated by converting a fixed constraint into an elastic constraint.
Parameters: 


returns an iterator that lists the combinations of orgset of length k
Parameters: 


Returns:  an iterator of the subsets 
example:
>>> c = combination([1,2,3,4],2)
>>> for s in c:
... print s
(1, 2)
(1, 3)
(1, 4)
(2, 3)
(2, 4)
(3, 4)
returns all permutations of orgset with up to k items
Parameters: 


Returns:  an iterator of the subsets 
example:
>>> c = allcombinations([1,2,3,4],2)
>>> for s in c:
... print s
(1,)
(2,)
(3,)
(4,)
(1, 2)
(1, 3)
(1, 4)
(2, 3)
(2, 4)
(3, 4)
returns an iterator that lists the permutations of orgset of length k
Parameters: 


Returns:  an iterator of the subsets 
example:
>>> c = permutation([1,2,3,4],2)
>>> for s in c:
... print s
(1, 2)
(1, 3)
(1, 4)
(2, 1)
(2, 3)
(2, 4)
(3, 1)
(3, 2)
(3, 4)
(4, 1)
(4, 2)
(4, 3)
returns all permutations of orgset with up to k items
Parameters: 


Returns:  an iterator of the subsets 
example:
>>> c = allpermutations([1,2,3,4],2)
>>> for s in c:
... print s
(1,)
(2,)
(3,)
(4,)
(1, 2)
(1, 3)
(1, 4)
(2, 1)
(2, 3)
(2, 4)
(3, 1)
(3, 2)
(3, 4)
(4, 1)
(4, 2)
(4, 3)