Skip to content

Commit 6fa840d

Browse files
committed
Adding an example file to run scheduler runs/tests
- Initial script to hopefully store any kind of test script that can run through the scheduler through its development - This may turn into a test script. It may turn into multiple example files...not sure yet - This is now the second working example of what's currently included (the first is what's at the bottom of scheduler.py)
1 parent d983e5d commit 6fa840d

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

famodel/irma/scheduler_example.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from famodel.irma.scheduler import Scheduler
2+
import numpy as np
3+
4+
5+
6+
# weather
7+
weather = [1, 1, 1, 1, 1]
8+
9+
# tasks
10+
tasks = [
11+
{
12+
'name': "install_mooring",
13+
'requirements': ['mooring_reel', 'positioning']
14+
},
15+
{
16+
'name': "install_anchor",
17+
'requirements': ['anchor_handling','positioning']
18+
}
19+
]
20+
21+
# assets
22+
assets = [
23+
{
24+
'name': 'AHTS',
25+
'capabilities': ['anchor_handling', 'mooring_reel', 'positioning'],
26+
'daily_cost': 50000,
27+
'max_weather': 2
28+
},
29+
{
30+
'name': 'MPSV',
31+
'capabilities': ['mooring_reel', 'positioning'],
32+
'daily_cost': 25000,
33+
'max_weather': 1
34+
}
35+
]
36+
37+
# task-asset matrix
38+
task_asset_matrix = np.array([
39+
[(2000, 2), (1000, 3), (2500, 3)],
40+
[(1500, 3), (-1, -1), (4000, 2)]
41+
])
42+
43+
# asset groups
44+
asset_groups = [
45+
{
46+
'assets': ['AHTS'],
47+
},
48+
{
49+
'assets': ['MPSV'],
50+
},
51+
{
52+
'assets': ['AHTS','MPSV'],
53+
},
54+
]
55+
56+
# task dependencies
57+
task_dependencies = {
58+
'install_mooring': ['install_anchor'] # Mooring installation depends on anchor installation
59+
}
60+
61+
# dependency types
62+
dependency_types = {
63+
'install_anchor->install_mooring': 'finish_start' # Anchor must finish before mooring starts
64+
}
65+
66+
# calculate the minimum duration
67+
min_duration = np.min(task_asset_matrix[:, :, 1][task_asset_matrix[:, :, 1] > 0]) # minimum non-zero duration
68+
69+
# intialize and run the scheduler
70+
scheduler = Scheduler(task_asset_matrix, tasks, assets, task_dependencies, dependency_types, weather, min_duration, asset_groups=asset_groups)
71+
scheduler.optimize()
72+

0 commit comments

Comments
 (0)