瀏覽代碼

rename parameter, move TIPS, add assignment HTML

Joeri Exelmans 10 月之前
父節點
當前提交
15925636d7
共有 6 個文件被更改,包括 186 次插入12 次删除
  1. 0 0
      assignment/doc/TIPS.txt
  2. 110 0
      assignment/doc/assignment.html
  3. 3 0
      assignment/doc/concept.svg
  4. 61 0
      assignment/doc/figures.drawio
  5. 10 10
      assignment/runner.py
  6. 2 2
      assignment/system.py

assignment/TIPS.txt → assignment/doc/TIPS.txt


File diff suppressed because it is too large
+ 110 - 0
assignment/doc/assignment.html


File diff suppressed because it is too large
+ 3 - 0
assignment/doc/concept.svg


+ 61 - 0
assignment/doc/figures.drawio

@@ -0,0 +1,61 @@
+<mxfile host="Electron" modified="2024-12-13T11:21:58.197Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/24.4.0 Chrome/126.0.6478.234 Electron/31.7.2 Safari/537.36" etag="HG30_Pus9FxNusYfN5k-" version="24.3.1" type="device">
+  <diagram name="Page-1" id="PQKqzUdAGHVOVxXedEcz">
+    <mxGraphModel dx="888" dy="728" grid="1" gridSize="10" guides="0" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
+      <root>
+        <mxCell id="0" />
+        <mxCell id="1" parent="0" />
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-3" style="rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="0JCrL0P5o5JfQ6rzsXf7-1" target="0JCrL0P5o5JfQ6rzsXf7-2">
+          <mxGeometry relative="1" as="geometry" />
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-1" value="Generator" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
+          <mxGeometry x="280" y="140" width="110" height="50" as="geometry" />
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-2" value="Queue" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
+          <mxGeometry x="300" y="250" width="70" height="50" as="geometry" />
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-4" value="Load Balancer" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
+          <mxGeometry x="280" y="360" width="110" height="50" as="geometry" />
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-5" value="Lock" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
+          <mxGeometry x="190" y="460" width="110" height="50" as="geometry" />
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-6" value="Lock" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
+          <mxGeometry x="340" y="460" width="110" height="50" as="geometry" />
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-7" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1" source="0JCrL0P5o5JfQ6rzsXf7-2" target="0JCrL0P5o5JfQ6rzsXf7-4">
+          <mxGeometry width="50" height="50" relative="1" as="geometry">
+            <mxPoint x="160" y="340" as="sourcePoint" />
+            <mxPoint x="210" y="290" as="targetPoint" />
+          </mxGeometry>
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-8" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1" source="0JCrL0P5o5JfQ6rzsXf7-4" target="0JCrL0P5o5JfQ6rzsXf7-5">
+          <mxGeometry width="50" height="50" relative="1" as="geometry">
+            <mxPoint x="329" y="300" as="sourcePoint" />
+            <mxPoint x="160" y="390" as="targetPoint" />
+          </mxGeometry>
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-9" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1" source="0JCrL0P5o5JfQ6rzsXf7-4" target="0JCrL0P5o5JfQ6rzsXf7-6">
+          <mxGeometry width="50" height="50" relative="1" as="geometry">
+            <mxPoint x="329" y="300" as="sourcePoint" />
+            <mxPoint x="160" y="390" as="targetPoint" />
+          </mxGeometry>
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-10" value="Sink" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
+          <mxGeometry x="280" y="560" width="70" height="50" as="geometry" />
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-12" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1" source="0JCrL0P5o5JfQ6rzsXf7-6" target="0JCrL0P5o5JfQ6rzsXf7-10">
+          <mxGeometry width="50" height="50" relative="1" as="geometry">
+            <mxPoint x="520" y="600" as="sourcePoint" />
+            <mxPoint x="570" y="550" as="targetPoint" />
+          </mxGeometry>
+        </mxCell>
+        <mxCell id="0JCrL0P5o5JfQ6rzsXf7-13" value="" style="endArrow=classic;html=1;rounded=0;" edge="1" parent="1" source="0JCrL0P5o5JfQ6rzsXf7-5" target="0JCrL0P5o5JfQ6rzsXf7-10">
+          <mxGeometry width="50" height="50" relative="1" as="geometry">
+            <mxPoint x="520" y="600" as="sourcePoint" />
+            <mxPoint x="570" y="550" as="targetPoint" />
+          </mxGeometry>
+        </mxCell>
+      </root>
+    </mxGraphModel>
+  </diagram>
+</mxfile>

+ 10 - 10
assignment/runner.py

@@ -31,9 +31,9 @@ strategies = {
 # The number of locks and their capacities
 lock_capacities=[3,2] # two locks, of capacity 3 and 2
 
-# The different parameters to try for lock_max_wait
-lock_max_waits = [ 0.0+i*120.0 for i in range(5) ] # all these values will be attempted
-# lock_max_waits = [ 15.0 ] # <-- uncomment if you only want to run an experiment with this value (useful for debugging)
+# The different parameters to try for max_wait_duration
+max_wait_durations = [ 0.0+i*120.0 for i in range(5) ] # all these values will be attempted
+# max_wait_durations = [ 15.0 ] # <-- uncomment if you only want to run an experiment with this value (useful for debugging)
 
 # How long does it take for a ship to pass through a lock
 passthrough_duration = 60.0*15 # 15 minutes
@@ -49,9 +49,9 @@ os.makedirs(outdir, exist_ok=True)
 for priority in priorities:
     for strategy in strategies:
         values = []
-        # and in each experiment, try a bunch of different values for the 'lock_max_wait' parameter:
-        for lock_max_wait in lock_max_waits:
-            print("Run simulation:", priorities[priority], strategies[strategy], "max_wait =",lock_max_wait)
+        # and in each experiment, try a bunch of different values for the 'max_wait_duration' parameter:
+        for max_wait_duration in max_wait_durations:
+            print("Run simulation:", priorities[priority], strategies[strategy], "max_wait =",max_wait_duration)
             sys = LockQueueingSystem(
                 # See system.py for explanation of these values:
                 seed=0,
@@ -61,7 +61,7 @@ for priority in priorities:
                 load_balancer_strategy=strategy,
                 lock_capacities=lock_capacities,
                 priority=priority,
-                lock_max_wait=lock_max_wait,
+                max_wait_duration=max_wait_duration,
                 passthrough_duration=passthrough_duration,
             )
             sim = Simulator(sys)
@@ -73,7 +73,7 @@ for priority in priorities:
             ships = sys.sink.state.ships
             values.append([ship.queueing_duration for ship in ships])
 
-        # Write out all the ship queueuing durations for every 'lock_max_wait' parameter
+        # Write out all the ship queueuing durations for every 'max_wait_duration' parameter
         #  for every ship, we write a line:
         #    <ship_num>, time_max_wait0, time_max_wait1, time_max_wait2, ... time_max_wait10
         filename = f'{outdir}/output_{strategies[strategy]}_{priorities[priority]}.csv'
@@ -91,13 +91,13 @@ for priority in priorities:
         plots_ships.append(make_plot_ships_script(
             priority=priorities[priority],
             strategy=strategies[strategy],
-            max_waits=lock_max_waits,
+            max_waits=max_wait_durations,
             gen_num=gen_num,
         ))
         plots_box.append(make_plot_box_script(
             priority=priorities[priority],
             strategy=strategies[strategy],
-            max_waits=lock_max_waits,
+            max_waits=max_wait_durations,
             gen_num=gen_num,
         ))
 

+ 2 - 2
assignment/system.py

@@ -17,7 +17,7 @@ class LockQueueingSystem(CoupledDEVS):
         load_balancer_strategy,
         lock_capacities,
         priority,
-        lock_max_wait,
+        max_wait_duration,
         passthrough_duration,
     ):
         super().__init__("LockQueueingSystem")
@@ -47,7 +47,7 @@ class LockQueueingSystem(CoupledDEVS):
 
         locks = [ self.addSubModel(Lock(
                     capacity=lock_capacity,
-                    max_wait_duration=lock_max_wait,
+                    max_wait_duration=max_wait_duration,
                     passthrough_duration=passthrough_duration))
                 for lock_capacity in lock_capacities ]