Python Package for Linear Decision Rule and Generalized Decision Rule

## Project description

Usage: Users are required to provide classes Algs and Simulator to SIM. Algs should inherit from algs. In the following example, we provide piecewise_linear(Algs) and SIM_Resolve_First(Simulator) to SIM. SIM.update() will solve the model, while SIM.avg(n) return simulation results.

Example:

from SIM import *

from SIM_Resolve_First import *

from piecewise_linear import *

case = SIM_Resolve_First()

algs = piecewise_linear()

sim = SIM(case,algs)

sim.update()

#sim.train_mab()

print sim.avg(1000)

Structure of Algs and Simulator:

SIM:

The only requirement of Simulator is having a function sim() to return a realization. If there are any parameters, they should be implemented in set_para(). SIM_Resolve_First.py and SIM_ALP.py are examples.

Algs:

Interfaces you should provide include lift_value(),relation(),strategy() and update(). Also, lifting method should be described in the class.

Example of Piecewise Linear:

for t in range(self.T):

for j in range(self.J):

for k in range(self.div_num):

self.div_axis[t,j,k] = self.low_bound[t,j] + (self.up_bound[t,j]-self.low_bound[t,j])/float(self.div_num - 1) * k

self.xi[t,j,k] = self.script.add_var(0,self.div_axis[t,j,k])

for t in range(self.T):

for j in range(self.J):

left = {}

for k in range(self.div_num):

left[self.xi[t,j,k]] = 1right = {}

right[self.constant] = 1

self.script.add_lin_equ(left,right)

for k in range(self.div_num):

self.script.add_lin_greater({self.xi[t,j,k]:1},{self.constant:0})for t in range(self.T):

for j in range(self.J):

left = {self.xi[t,j]:1}

right = {}

for k in range(self.div_num):

right[self.xi[t,j,k]] = self.div_axis[t,j,k]self.script.add_lin_equ(left,right)

lift_value(data):

return lift value for a realization.

relation():

set up dependence self.P for items. For example, if decision X(t,j) depends on first three elements of lifted vector, then self.P[t,j] = {1,2,3}

strategy(t,history,x):

return strategy at stage t with history and optimized decision variable x.

update():

update lifting methods.

piecewise_linear.py and tri_linear.py are examples of Algs.

## Project details

## Release history Release notifications

## Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help | File type | Python version | Upload date |
---|---|---|---|

pyldr-0.1.2.tar.gz (18.9 kB) Copy SHA256 hash SHA256 | Source | None |