pyepo.model.ort.knapsack

Knapsack problem

Attributes

_HAS_ORTOOLS

cost

Classes

knapsackModel

This class is an optimization model for the knapsack problem

knapsackModelRel

This class is relaxed optimization model for knapsack problem.

knapsackCpModel

This class is an optimization model for the knapsack problem using CP-SAT

Module Contents

pyepo.model.ort.knapsack._HAS_ORTOOLS = True
class pyepo.model.ort.knapsack.knapsackModel(weights, capacity, solver='scip')

Bases: pyepo.model.ort.ortmodel.optOrtModel

This class is an optimization model for the knapsack problem

_model

OR-Tools linear solver

Type:

pywraplp.Solver

solver

solver backend

Type:

str

weights

weights of items

Type:

np.ndarray

capacity

total capacity

Type:

np.ndarray

items

list of item index

Type:

list

weights
capacity
items
_getModel()

A method to build OR-Tools pywraplp model

Returns:

optimization model and variables

Return type:

tuple

relax()

A method to get linear relaxation model

class pyepo.model.ort.knapsack.knapsackModelRel(weights, capacity, solver='scip')

Bases: knapsackModel

This class is relaxed optimization model for knapsack problem.

_getModel()

A method to build OR-Tools pywraplp model (relaxed)

Returns:

optimization model and variables

Return type:

tuple

relax()

A forbidden method to relax MIP model

class pyepo.model.ort.knapsack.knapsackCpModel(weights, capacity)

Bases: pyepo.model.ort.ortcpmodel.optOrtCpModel

This class is an optimization model for the knapsack problem using CP-SAT

_model

OR-Tools CP-SAT model

Type:

cp_model.CpModel

weights

weights of items

Type:

np.ndarray

capacity

total capacity

Type:

np.ndarray

items

list of item index

Type:

list

weights
capacity
items
_getModel()

A method to build OR-Tools CP-SAT model

Returns:

optimization model and variables

Return type:

tuple

pyepo.model.ort.knapsack.cost