-
Notifications
You must be signed in to change notification settings - Fork 5
/
zoocallopl.py
38 lines (29 loc) · 867 Bytes
/
zoocallopl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from doopl.factory import *
# Data
Buses=[
(40,500),
(30,400)
]
# Create an OPL model from a .mod file
with create_opl_model(model="zootupleset.mod") as opl:
# tuple can be a list of tuples, a pandas dataframe...
opl.set_input("buses", Buses)
# Generate the problem and solve it.
opl.run()
# Get the names of post processing tables
print("Table names are: "+ str(opl.output_table_names))
# Get all the post processing tables as dataframes.
for name, table in iteritems(opl.report):
print("Table : " + name)
for t in table.itertuples(index=False):
print(t)
# nicer display
for t in table.itertuples(index=False):
print(t[0]," buses ",t[1], "seats")
'''
which gives
Pandas(nbBus=6, sizeBus=40)
Pandas(nbBus=2, sizeBus=30)
6 buses 40 seats
2 buses 30 seats
'''