Skip to main content

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.


from SIM import *

from SIM_Resolve_First import *

from piecewise_linear import *

case = SIM_Resolve_First()

algs = piecewise_linear()

sim = SIM(case,algs)



print sim.avg(1000)

Structure of Algs and Simulator:


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(). and are examples.


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]] = 1

right = {}

right[self.constant] = 1


for k in range(self.div_num):


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]



return lift value for a realization.


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}


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


update lifting methods. and are examples of Algs.

Project details

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

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page