-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (45 loc) · 1.76 KB
/
main.py
File metadata and controls
59 lines (45 loc) · 1.76 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import json
import xml.etree.ElementTree as ElementTree
import o2.optimizer
import o2.store
from o2.models.constraints import ConstraintsType
from o2.models.settings import AgentType
from o2.models.timetable import TimetableType
def main() -> None:
# timetable_path = "examples/demo_batching/timetable.json"
# constraints_path = "examples/demo_batching/constraints.json"
# bpmn_path = "examples/demo_batching/model.bpmn"
timetable_path = "examples/demo_legacy/timetable.json"
constraints_path = "examples/demo_legacy/constraints.json"
bpmn_path = "examples/demo_legacy/model.bpmn"
# timetable_path = "examples/purchase_timetable.json"
# constraints_path = "examples/purchase_constraints.json"
# bpmn_path = "examples/purchase.bpmn"
with open(timetable_path) as f:
timetable = TimetableType.from_dict(json.load(f))
with open(constraints_path) as f:
constraints = ConstraintsType.from_dict(json.load(f))
with open(bpmn_path) as f:
bpmn_definition = f.read()
initial_state = o2.store.State(
bpmn_definition=bpmn_definition,
timetable=timetable,
)
store = o2.store.Store.from_state_and_constraints(
initial_state,
constraints,
)
# Change settings here:
# store.settings.[...] = ...
# Enable legacy mode
store.settings.optimos_legacy_mode = True
store.settings.max_iterations = 1000
store.settings.max_non_improving_actions = 200
store.settings.sa_initial_temperature = 5_000_000_000
store.settings.sa_cooling_factor = 0.90
store.settings.agent = AgentType.SIMULATED_ANNEALING
optimizer = o2.optimizer.Optimizer(store)
optimizer.solve()
# SimulationRunner.run_simulation(store.state)
if __name__ == "__main__":
main()