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]] = 1
right = {}
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 | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyldr-0.1.2.tar.gz.
File metadata
- Download URL: pyldr-0.1.2.tar.gz
- Upload date:
- Size: 18.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
476603e4762ee34193bd402f3a075d0f9ea6c9a0bf7b7a84694f97ae33e7c271
|
|
| MD5 |
224b04a08d993eacdd466b7453a3a520
|
|
| BLAKE2b-256 |
7ebe54541d1232f4d9407b3b9e466f383d94e976644b5623dceb7cffbfbf1284
|