diff --git a/introduction_salabim.ipynb b/introduction_salabim.ipynb index 8ea7529..a0337a5 100644 --- a/introduction_salabim.ipynb +++ b/introduction_salabim.ipynb @@ -67,7 +67,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "77bc1c02", "metadata": {}, "outputs": [ @@ -75,7 +75,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "time = 5\n" + "time = 5.0\n" ] } ], @@ -142,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "id": "08b57a6b", "metadata": { "collapsed": true @@ -154,7 +154,7 @@ "text": [ "line# time current component action information\n", "------ ---------- -------------------- ----------------------------------- ------------------------------------------------\n", - " line numbers refers to 4157391535.py\n", + " line numbers refers to 2711253970.py\n", " 12 default environment initialize \n", " 12 main create \n", " 12 0.000 main current \n", @@ -164,7 +164,7 @@ " 8+ 0.000 person.0 current \n", " 9 person.0 hold +1.000 scheduled for 1.000 @ 9+\n", " 9+ 1.000 person.0 current \n", - " 9+ person.0 ended \n", + " person.0 ended \n", " 17+ 10.000 main current \n" ] } @@ -178,7 +178,7 @@ " \n", " # the process method automatically runs once the simulation starts i.e. env.run() \n", " def process(self): \n", - " yield self.hold(1)\n", + " self.hold(1)\n", " \n", "# each salabim simulation needs a environment \n", "env=sim.Environment(trace=True)\n", @@ -200,7 +200,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "id": "25093dfe", "metadata": {}, "outputs": [ @@ -210,7 +210,7 @@ "text": [ "line# time current component action information\n", "------ ---------- -------------------- ----------------------------------- ------------------------------------------------\n", - " line numbers refers to 53082488.py\n", + " line numbers refers to 969392242.py\n", " 9 default environment initialize \n", " 9 main create \n", " 9 0.000 main current \n", @@ -237,8 +237,8 @@ "class Person(sim.Component): \n", " def process(self): \n", " while True:\n", - " yield self.hold(2,mode='walk')\n", - " yield self.hold(0.5,mode='rest')\n", + " self.hold(2,mode='walk')\n", + " self.hold(0.5,mode='rest')\n", "\n", "env=sim.Environment(trace=True)\n", "\n", @@ -257,7 +257,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 4, "id": "c15c0f0a", "metadata": {}, "outputs": [ @@ -267,7 +267,7 @@ "text": [ "line# time current component action information\n", "------ ---------- -------------------- ----------------------------------- ------------------------------------------------\n", - " line numbers refers to 3293430043.py\n", + " line numbers refers to 1417863241.py\n", " 7 default environment initialize \n", " 7 main create \n", " 7 0.000 main current \n", @@ -277,7 +277,7 @@ " 4+ 0.000 person.0 current \n", " 5 person.0 hold +1.000 scheduled for 1.000 @ 5+\n", " 5+ 1.000 person.0 current \n", - " 5+ person.0 ended \n", + " person.0 ended \n", " 11+ 10.000 main current \n" ] } @@ -287,7 +287,7 @@ "\n", "class Person(sim.Component):\n", " def walking(self): \n", - " yield self.hold(1) \n", + " self.hold(1) \n", " \n", "env=sim.Environment(trace=True)\n", "\n", @@ -454,7 +454,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 5, "id": "67105852", "metadata": { "collapsed": true @@ -466,7 +466,7 @@ "text": [ "line# time current component action information\n", "------ ---------- -------------------- ----------------------------------- ------------------------------------------------\n", - " line numbers refers to 4105219571.py\n", + " line numbers refers to 2713596784.py\n", " 13 default environment initialize \n", " 13 main create \n", " 13 0.000 main current \n", @@ -486,7 +486,7 @@ "At time 2.0 the state of Person (person.0) is scheduled\n", " 10 checker.0 hold +1.000 scheduled for 3.000 @ 10+\n", " 5+ 3.000 person.0 current \n", - " 5+ person.0 ended \n", + " person.0 ended \n", " 10+ 3.000 checker.0 current \n", "At time 3.0 the state of Person (person.0) is data\n", " 10 checker.0 hold +1.000 scheduled for 4.000 @ 10+\n", @@ -505,12 +505,12 @@ "\n", "class Person(sim.Component):\n", " def process(self): \n", - " yield self.hold(3)\n", + " self.hold(3)\n", " \n", "class Checker(sim.Component):\n", " def process(self): \n", " while True:\n", - " yield self.hold(1) \n", + " self.hold(1) \n", " print(f'At time {env.now()} the state of {p0} is {p0.status()}')\n", "\n", "env=sim.Environment(trace=True)\n", @@ -534,7 +534,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 6, "id": "c821d301", "metadata": { "collapsed": true @@ -562,16 +562,16 @@ "\n", "class Person(sim.Component):\n", " def process(self): \n", - " yield self.hold(3)\n", + " self.hold(3)\n", " \n", "class Checker(sim.Component):\n", " def process(self): \n", " while True:\n", - " yield self.hold(1) \n", + " self.hold(1) \n", " print(f'At time {env.now()} the state of {p0} is {p0.status()}')\n", " \n", " if env.now()==5 and p0.status()=='data':\n", - " p1.activate()\n", + " p0.activate()\n", "\n", "env=sim.Environment()\n", "\n", @@ -623,7 +623,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 7, "id": "a82a96f3", "metadata": {}, "outputs": [ @@ -644,7 +644,7 @@ " def process(self): \n", " self.number_of_holds=0\n", " while True:\n", - " yield self.hold(1) \n", + " self.hold(1) \n", " print(f'I am {self.status()}') \n", " \n", "env=sim.Environment()\n", @@ -665,7 +665,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 8, "id": "dc9c342f", "metadata": {}, "outputs": [ @@ -691,14 +691,14 @@ " def process(self): \n", " self.number_of_holds=0\n", " while True:\n", - " yield self.hold(1) \n", + " self.hold(1) \n", " print(f'At time {env.now()} the state of {self.name()} is {self.status()}') \n", - " yield self.hold(1) \n", + " self.hold(1) \n", " \n", "class Checker(sim.Component):\n", " def process(self): \n", " while True:\n", - " yield self.hold(1) \n", + " self.hold(1) \n", " print(f'At time {env.now()} the state of {p0.name()} is {p0.status()}') \n", "\n", "env=sim.Environment()\n", @@ -740,7 +740,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "id": "7f35bc61", "metadata": {}, "outputs": [ @@ -748,12 +748,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "At time 0.0 FEL [(0.0, 0, 3, 'person.0'), (5, inf, 2, 'main')]\n", - "At time 1.0 FEL [(1.0, 0, 5, 'person.0'), (5, inf, 2, 'main'), (1.0, 0, 6, 'person.1')]\n", - "At time 2.0 FEL [(2.0, 0, 8, 'person.1'), (5, inf, 2, 'main'), (2.0, 0, 9, 'person.2')]\n", - "At time 3.0 FEL [(3.0, 0, 11, 'person.2'), (5, inf, 2, 'main'), (3.0, 0, 12, 'person.3')]\n", - "At time 4.0 FEL [(4.0, 0, 14, 'person.3'), (5, inf, 2, 'main'), (4.0, 0, 15, 'person.4')]\n", - "At time 5.0 FEL [(5.0, 0, 17, 'person.4'), (5, inf, 2, 'main'), (5.0, 0, 18, 'person.5')]\n" + "At time 0.0 FEL [(0.0, 0, 3, 'person.0'), (5.0, inf, 2, 'main')]\n", + "At time 1.0 FEL [(1.0, 0, 5, 'person.0'), (5.0, inf, 2, 'main'), (1.0, 0, 6, 'person.1')]\n", + "At time 2.0 FEL [(2.0, 0, 8, 'person.1'), (5.0, inf, 2, 'main'), (2.0, 0, 9, 'person.2')]\n", + "At time 3.0 FEL [(3.0, 0, 11, 'person.2'), (5.0, inf, 2, 'main'), (3.0, 0, 12, 'person.3')]\n", + "At time 4.0 FEL [(4.0, 0, 14, 'person.3'), (5.0, inf, 2, 'main'), (4.0, 0, 15, 'person.4')]\n", + "At time 5.0 FEL [(5.0, 0, 17, 'person.4'), (5.0, inf, 2, 'main'), (5.0, 0, 18, 'person.5')]\n" ] } ], @@ -762,14 +762,14 @@ "\n", "class Person(sim.Component):\n", " def process(self):\n", - " yield self.hold(1) \n", + " self.hold(1) \n", " \n", "class Checker(sim.Component):\n", " def process(self): \n", " while True:\n", " Person()\n", " print(f'At time {env.now()} FEL {[(i[0],i[1],i[2],i[3].name()) for i in env._event_list]}') \n", - " yield self.hold(1) \n", + " self.hold(1) \n", " \n", "env=sim.Environment()\n", "\n", @@ -816,7 +816,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 10, "id": "8524a74a", "metadata": {}, "outputs": [ @@ -837,14 +837,14 @@ "class Person(sim.Component):\n", " def process(self): \n", " while True:\n", - " yield self.hold(1) \n", - " yield self.passivate() \n", + " self.hold(1) \n", + " self.passivate() \n", " print(f'At time {env.now()} {self.name()} was woken up, its status is: {self.status()}') \n", " \n", "class Checker(sim.Component):\n", " def process(self): \n", " while True:\n", - " yield self.hold(3) \n", + " self.hold(3) \n", " print(f'At time {env.now()} {self.name()} activated {p0.name()} from state: {p0.status()}') \n", " p0.activate()\n", " \n", @@ -888,7 +888,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 11, "id": "a7474bbd", "metadata": {}, "outputs": [ @@ -910,15 +910,15 @@ "\n", "class Person(sim.Component):\n", " def process(self): \n", - " yield self.hold(1) \n", - " yield self.request(ticket_office) \n", - " yield self.hold(1,mode='buying ticket') \n", + " self.hold(1) \n", + " self.request(ticket_office) \n", + " self.hold(1,mode='buying ticket') \n", " self.release() \n", " \n", "class Checker(sim.Component):\n", " def process(self): \n", " while True:\n", - " yield self.hold(1) \n", + " self.hold(1) \n", " print(f'At time {env.now()} the status of {p0.name()} is: {p0.status()}') \n", " if env.now()==3:\n", " ticket_office.set_capacity(cap=1)\n", @@ -978,7 +978,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 12, "id": "4876d10f", "metadata": {}, "outputs": [ @@ -1000,15 +1000,15 @@ "\n", "class Person(sim.Component):\n", " def process(self): \n", - " yield self.hold(1) \n", - " yield self.wait(ticket_office) \n", - " yield self.hold(1,mode='buying ticket') \n", + " self.hold(1) \n", + " self.wait(ticket_office) \n", + " self.hold(1,mode='buying ticket') \n", " ticket_office.reset()\n", " \n", "class Checker(sim.Component):\n", " def process(self): \n", " while True:\n", - " yield self.hold(1) \n", + " self.hold(1) \n", " print(f'At time {env.now()} the status of {p0.name()} is: {p0.status()}') \n", " if env.now()==3:\n", " ticket_office.set()\n", @@ -1051,7 +1051,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 13, "id": "ea1149e2", "metadata": {}, "outputs": [ @@ -1072,14 +1072,14 @@ "class Car(sim.Component): \n", " def process(self): \n", " while True:\n", - " yield self.standby(mode='waiting')\n", + " self.standby(mode='waiting')\n", " print(f'At time {env.now()} {self.name()} came out of standby') \n", " \n", "class Bike(sim.Component):\n", " def process(self): \n", " while True:\n", - " yield self.hold(1,mode='drive') \n", - " yield self.hold(1,mode='stop') \n", + " self.hold(1,mode='drive') \n", + " self.hold(1,mode='stop') \n", "\n", "env=sim.Environment()\n", "mycar=Car()\n", @@ -1114,7 +1114,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 14, "id": "f6a45587", "metadata": { "collapsed": true @@ -1139,12 +1139,12 @@ "\n", "class Person(sim.Component):\n", " def process(self): \n", - " yield self.hold(5) \n", + " self.hold(5) \n", " \n", "class Checker(sim.Component):\n", " def process(self): \n", " while True:\n", - " yield self.hold(1) \n", + " self.hold(1) \n", " print(f'At time {env.now()} the state of {p0} is {p0.status()}')\n", " \n", " if env.now()==1:\n", @@ -1181,7 +1181,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.1" + "version": "3.12.7" } }, "nbformat": 4,