diff --git a/CarSharing.mo b/CarSharing.mo deleted file mode 100644 index f56ade4493ed673f3718aa0723352d35de194978..0000000000000000000000000000000000000000 --- a/CarSharing.mo +++ /dev/null @@ -1,61 +0,0 @@ -model CarSharing - PNlib.Components.PD PSCii(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-72, 8}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); - PNlib.Components.TES TCRi(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-44, -28}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.PD PSRi(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-8, 0}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.PD PSCi(nIn = 1, nOut = 1, startTokens = 6) annotation( - Placement(transformation(origin = {-6, 34}, extent = {{10, -10}, {-10, 10}}, rotation = -0))); - PNlib.Components.T TUSi(nIn = 2, nOut = 2) annotation( - Placement(transformation(origin = {32, 0}, extent = {{-14, -14}, {14, 14}}))); - PNlib.Components.PD PCU(nIn = 1, nOut = 1, startTokens = 5) annotation( - Placement(transformation(origin = {86, 22}, extent = {{10, -10}, {-10, 10}}, rotation = -90))); - PNlib.Components.PD PSDi(nIn = 1, nOut = 2, startTokens = 1) annotation( - Placement(transformation(origin = {-36, -72}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TD TUNi(nIn = 1) annotation( - Placement(transformation(origin = {54, -72}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TES TUDi(nOut = 1) annotation( - Placement(transformation(origin = {-80, -72}, extent = {{-10, -10}, {10, 10}}))); - inner PNlib.Components.Settings settings(showTokenFlow = true) annotation( - Placement(transformation(origin = {-168, 98}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TES TCCi(nIn = 2, nOut = 1) annotation( - Placement(transformation(origin = {-44, 62}, extent = {{10, -10}, {-10, 10}}, rotation = -0))); -equation - connect(TUDi.outPlaces, PSDi.inTransition) annotation( - Line(points = {{-76, -72}, {-46, -72}}, thickness = 0.5)); - connect(TUSi.outPlaces[1], PCU.inTransition[1]) annotation( - Line(points = {{38, 0}, {86, 0}, {86, 12}}, thickness = 0.5)); - connect(TUSi.outPlaces[2], PSCi.inTransition[1]) annotation( - Line(points = {{38, 0}, {48, 0}, {48, 33}, {4, 33}, {4, 34}}, thickness = 0.5)); - connect(PSRi.outTransition[1], TUSi.inPlaces[1]) annotation( - Line(points = {{2, 0}, {26, 0}}, thickness = 0.5)); - connect(PSDi.outTransition[1], TUSi.inPlaces[2]) annotation( - Line(points = {{-26, -72}, {20, -72}, {20, 0}, {26, 0}}, thickness = 0.5)); - connect(PSDi.outTransition[2], TUNi.inPlaces[1]) annotation( - Line(points = {{-26, -72}, {50, -72}}, thickness = 0.5)); - connect(PSCi.outTransition[1], TCCi.inPlaces[1]) annotation( - Line(points = {{-16, 34}, {-40, 34}, {-40, 62}}, thickness = 0.5)); - connect(PCU.outTransition[1], TCCi.inPlaces[2]) annotation( - Line(points = {{86, 32}, {54.5, 32}, {54.5, 66}, {55, 66}, {55, 64}, {24, 64}, {24, 65}, {-40, 65}, {-40, 62}}, thickness = 0.5)); - connect(TCCi.outPlaces[1], PSCii.inTransition[1]) annotation( - Line(points = {{-48, 62}, {-72, 62}, {-72, 18}}, thickness = 0.5)); - connect(PSCii.outTransition[1], TCRi.inPlaces[1]) annotation( - Line(points = {{-72, -2}, {-48, -2}, {-48, -28}}, thickness = 0.5)); - connect(TCRi.outPlaces[1], PSRi.inTransition[1]) annotation( - Line(points = {{-40, -28}, {-18, -28}, {-18, 0}}, thickness = 0.5)); - annotation( - uses(PNlib(version = "3.0.0")), - Diagram(graphics = {Text(origin = {-166, -72}, extent = {{74, -9}, {0, 9}}, textString = "User demand arrival at station -(stochastic transition)"), Text(origin = {-103, -96}, extent = {{3, 0}, {-3, 0}}, textString = "text"), Text(origin = {-26, -106}, extent = {{68, -24}, {-68, 24}}, textString = "Users (demands) waiting -during a given random -delay- for available and ready cars in the station."), Text(origin = {90, -95}, extent = {{-54, 23}, {54, -23}}, textString = "User demand “not satisfied” at station. The -user leaves the station without having been -served. (Deterministic transition)"), Text(origin = {-109, -30}, extent = {{-45, 28}, {45, -28}}, textString = "Car is ready after its charging operation -(stochastic transition)"), Text(origin = {-133, 11}, extent = {{-43, 21}, {43, -21}}, textString = "Cars parked at the station but still -under charging, not yet available for users."), Text(origin = {-9, 88}, extent = {{-57, 14}, {57, -14}}, textString = "Cars return to station by user. -Then, the car is in a charging situation -(stochastic transition)"), Text(origin = {23, 51}, extent = {{-49, 9}, {49, -9}}, textString = "Cars parked at the station but still -under charging, not yet available for users."), Text(origin = {-6, 15}, extent = {{-24, 5}, {24, -5}}, textString = "Cars are ready"), Text(origin = {72, -21}, extent = {{-42, 17}, {42, -17}}, textString = "User demand \"satisfied\", -then \"user departure\" from station. -(immediate transition)"), Text(origin = {87, 38}, extent = {{-13, 4}, {13, -4}}, textString = "Cars in use")})); -end CarSharing; diff --git a/CarSharingSystem.mo b/CarSharingSystem.mo deleted file mode 100644 index 8efdc84554d6a96fb1f153e6ee5b1bf35b3f0e7f..0000000000000000000000000000000000000000 --- a/CarSharingSystem.mo +++ /dev/null @@ -1,163 +0,0 @@ -<<<<<<< HEAD -model CarSharing -======= -model CarSharingSystem - - // Parameters - parameter Integer numCars = 50 "Number of cars in the system"; - parameter Integer numUsers = 50 "Number of users in the system"; - - // Discrete Places ->>>>>>> origin/master - PNlib.Components.PD PSCii(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-306, 90}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); - PNlib.Components.TES TCRi(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-278, 54}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.PD PSRi(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-242, 82}, extent = {{-10, -10}, {10, 10}}))); -<<<<<<< HEAD - PNlib.Components.PD PSCi(nIn = 1, nOut = 1, startTokens = 6) annotation( - Placement(transformation(origin = {-240, 116}, extent = {{10, -10}, {-10, 10}}))); - PNlib.Components.T TUSi(nIn = 2, nOut = 2) annotation( - Placement(transformation(origin = {-202, 82}, extent = {{-14, -14}, {14, 14}}))); - PNlib.Components.PD PCU(nIn = 3, nOut = 4, startTokens = 5) annotation( - Placement(transformation(origin = {26, 36}, extent = {{20, -20}, {-20, 20}}, rotation = -90))); - PNlib.Components.PD PSDi(nIn = 1, nOut = 2, startTokens = 1) annotation( -======= - PNlib.Components.PD PSCi(nIn = 1, nOut = 1, startTokens = numCars) annotation( - Placement(transformation(origin = {-240, 116}, extent = {{10, -10}, {-10, 10}}))); - PNlib.Components.T TUSi(nIn = 2, nOut = 2) annotation( - Placement(transformation(origin = {-202, 82}, extent = {{-14, -14}, {14, 14}}))); - PNlib.Components.PD PCU(nIn = 3, nOut = 4, startTokens = 0) annotation( - Placement(transformation(origin = {26, 36}, extent = {{20, -20}, {-20, 20}}, rotation = -90))); - PNlib.Components.PD PSDi(nIn = 1, nOut = 2, startTokens = numUsers) annotation( ->>>>>>> origin/master - Placement(transformation(origin = {-270, 10}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TD TUNi(nIn = 1) annotation( - Placement(transformation(origin = {-180, 10}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TES TUDi(nOut = 1) annotation( - Placement(transformation(origin = {-314, 10}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TES TCCi(nIn = 2, nOut = 1) annotation( - Placement(transformation(origin = {-272, 144}, extent = {{10, -10}, {-10, 10}}))); - PNlib.Components.PD PSCii1(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-132, -56}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); - PNlib.Components.TES TCRi1(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-104, -92}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.PD PSRi1(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-68, -64}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.PD PSCi1(nIn = 1, nOut = 1, startTokens = 6) annotation( - Placement(transformation(origin = {-66, -30}, extent = {{10, -10}, {-10, 10}}))); - PNlib.Components.T TUSi1(nIn = 2, nOut = 2) annotation( - Placement(transformation(origin = {-28, -64}, extent = {{-14, -14}, {14, 14}}))); - PNlib.Components.PD PSDi1(nIn = 1, nOut = 2, startTokens = 1) annotation( - Placement(transformation(origin = {-96, -136}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TD TUNi1(nIn = 1) annotation( - Placement(transformation(origin = {-6, -136}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TES TUDi1(nOut = 1) annotation( - Placement(transformation(origin = {-140, -136}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TES TCCi1(nIn = 2, nOut = 1) annotation( - Placement(transformation(origin = {-104, -2}, extent = {{10, -10}, {-10, 10}}))); - PNlib.Components.TES TCM(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {216, 142}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.PD PCM(nIn = 1, nOut = 1, startTokens = 2) annotation( - Placement(transformation(origin = {382, 178}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TES TMPR(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {384, 74}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.PD PCU_1(nIn = 2, nOut = 1, startTokens = 3) annotation( - Placement(transformation(origin = {392, -8}, extent = {{10, -10}, {-10, 10}}))); - PNlib.Components.TES TCPR(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {342, -94}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.PD PCU_2(nIn = 1, nOut = 1, startTokens = 1) annotation( - Placement(transformation(origin = {252, -130}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.TES TCPc(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {166, -92}, extent = {{-10, -10}, {10, 10}}))); - PNlib.Components.T TUSp(nIn = 2, nOut = 1) annotation( - Placement(transformation(origin = {117, -7}, extent = {{21, -21}, {-21, 21}}))); - PNlib.Components.TES TUDp(nIn = 0, nOut = 1) annotation( - Placement(transformation(origin = {336, 72}, extent = {{10, -10}, {-10, 10}}))); - PNlib.Components.PD P1(nIn = 1, nOut = 2) annotation( - Placement(transformation(origin = {278, 74}, extent = {{10, -10}, {-10, 10}}))); - PNlib.Components.TDS TUNp(nIn = 1) annotation( - Placement(transformation(origin = {144, 82}, extent = {{10, -10}, {-10, 10}}))); - inner PNlib.Components.Settings settings(showTokenFlow = true) annotation( - Placement(transformation(origin = {-356, 208}, extent = {{-10, -10}, {10, 10}}))); -equation - connect(TUDi.outPlaces, PSDi.inTransition) annotation( - Line(points = {{-309.2, 10}, {-279.2, 10}}, thickness = 0.5)); - connect(TUSi.outPlaces[1], PCU.inTransition[1]) annotation( - Line(points = {{-195.28, 82}, {-77.92, 82}, {-77.92, 14}, {26, 14}}, thickness = 0.5)); - connect(TUSi.outPlaces[2], PSCi.inTransition[1]) annotation( - Line(points = {{-195.28, 82}, {-185.28, 82}, {-185.28, 115}, {-229.28, 115}, {-229.28, 116}}, thickness = 0.5)); - connect(PSRi.outTransition[1], TUSi.inPlaces[1]) annotation( - Line(points = {{-231.2, 82}, {-207.2, 82}}, thickness = 0.5)); - connect(PSDi.outTransition[1], TUSi.inPlaces[2]) annotation( - Line(points = {{-259.2, 10}, {-213.2, 10}, {-213.2, 82}, {-207.2, 82}}, thickness = 0.5)); - connect(PSDi.outTransition[2], TUNi.inPlaces[1]) annotation( - Line(points = {{-259.2, 10}, {-183.2, 10}}, thickness = 0.5)); - connect(PSCi.outTransition[1], TCCi.inPlaces[1]) annotation( - Line(points = {{-250.8, 116}, {-267, 116}, {-267, 144}}, thickness = 0.5)); - connect(PCU.outTransition[1], TCCi.inPlaces[2]) annotation( - Line(points = {{26, 58}, {26, 143.2}, {-132, 143.2}, {-132, 144.2}, {-267, 144.2}, {-267, 143.6}}, thickness = 0.5)); - connect(TCCi.outPlaces[1], PSCii.inTransition[1]) annotation( - Line(points = {{-276.8, 144}, {-306.6, 144}, {-306.6, 100}}, thickness = 0.5)); - connect(PSCii.outTransition[1], TCRi.inPlaces[1]) annotation( - Line(points = {{-306, 79.2}, {-282, 79.2}, {-282, 53.2}}, thickness = 0.5)); - connect(TCRi.outPlaces[1], PSRi.inTransition[1]) annotation( - Line(points = {{-273.2, 54}, {-251.2, 54}, {-251.2, 82}}, thickness = 0.5)); - connect(TUDi1.outPlaces, PSDi1.inTransition) annotation( - Line(points = {{-135.2, -136}, {-107.2, -136}}, thickness = 0.5)); - connect(PSRi1.outTransition[1], TUSi1.inPlaces[1]) annotation( - Line(points = {{-57.2, -64}, {-35.2, -64}}, thickness = 0.5)); - connect(PSDi1.outTransition[1], TUSi1.inPlaces[2]) annotation( - Line(points = {{-85.2, -136}, {-45.4, -136}, {-45.4, -64}, {-35.2, -64}}, thickness = 0.5)); - connect(PSDi1.outTransition[2], TUNi1.inPlaces[1]) annotation( - Line(points = {{-85.2, -136}, {-11.2, -136}}, thickness = 0.5)); - connect(PSCi1.outTransition[1], TCCi1.inPlaces[1]) annotation( - Line(points = {{-76.8, -30}, {-98.8, -30}, {-98.8, -2}}, thickness = 0.5)); - connect(TCCi1.outPlaces[1], PSCii1.inTransition[1]) annotation( - Line(points = {{-108.8, -2}, {-131.8, -2}, {-131.8, -45}}, thickness = 0.5)); - connect(PSCii1.outTransition[1], TCRi1.inPlaces[1]) annotation( - Line(points = {{-132, -66.8}, {-109, -66.8}, {-109, -91.8}}, thickness = 0.5)); - connect(TCRi1.outPlaces[1], PSRi1.inTransition[1]) annotation( - Line(points = {{-99.2, -92}, {-79.2, -92}, {-79.2, -64}}, thickness = 0.5)); - connect(PCU.outTransition[2], TCCi1.inPlaces[2]) annotation( - Line(points = {{26, 58}, {-4, 58}, {-4, 117.2}, {-99, 117.2}, {-99, -2.4}}, thickness = 0.5)); - connect(TCM.outPlaces[1], PCM.inTransition[1]) annotation( - Line(points = {{221, 142}, {261, 142}, {261, 178}, {371, 178}}, thickness = 0.5)); - connect(PCM.outTransition[1], TMPR.inPlaces[1]) annotation( - Line(points = {{393, 178}, {407, 178}, {407, 80.5}, {379, 80.5}, {379, 74}}, thickness = 0.5)); - connect(TMPR.outPlaces[1], PCU_1.inTransition[1]) annotation( - Line(points = {{389, 74}, {450, 74}, {450, -8}, {403, -8}}, thickness = 0.5)); - connect(TCPR.outPlaces[1], PCU_1.inTransition[2]) annotation( - Line(points = {{347, -94}, {347, -51}, {403, -51}, {403, -8}}, thickness = 0.5)); - connect(PCU_2.outTransition[1], TCPR.inPlaces[1]) annotation( - Line(points = {{263, -130}, {337, -130}, {337, -94}}, thickness = 0.5)); - connect(TCPc.outPlaces[1], PCU_2.inTransition[1]) annotation( - Line(points = {{171, -92}, {241, -92}, {241, -130}}, thickness = 0.5)); - connect(PCU_1.outTransition[1], TUSp.inPlaces[1]) annotation( - Line(points = {{381, -8}, {127, -8}, {127, -7}}, thickness = 0.5)); - connect(TUDp.outPlaces[1], P1.inTransition[1]) annotation( - Line(points = {{331, 72}, {326, 72}, {326, 74}, {289, 74}}, thickness = 0.5)); - connect(P1.outTransition[1], TUNp.inPlaces[1]) annotation( - Line(points = {{267, 74}, {149, 74}, {149, 82}}, thickness = 0.5)); - connect(P1.outTransition[2], TUSp.inPlaces[2]) annotation( - Line(points = {{267, 74}, {242, 74}, {242, 22}, {127, 22}, {127, -7}}, thickness = 0.5)); - connect(TUSp.outPlaces[1], PCU.inTransition[3]) annotation( - Line(points = {{107, -7}, {90, -7}, {90, 14}, {26, 14}}, thickness = 0.5)); - connect(PCU.outTransition[3], TCM.inPlaces[1]) annotation( - Line(points = {{26, 58}, {211, 58}, {211, 142}}, thickness = 0.5)); - connect(PCU.outTransition[4], TCPc.inPlaces[1]) annotation( - Line(points = {{26, 58}, {70, 58}, {70, -85.5}, {71, -85.5}, {71, -91.75}, {161, -91.75}, {161, -92}}, thickness = 0.5)); - connect(TUSi1.outPlaces[2], PCU.inTransition[2]) annotation( - Line(points = {{-22, -64}, {26, -64}, {26, 14}}, thickness = 0.5)); - connect(TUSi1.outPlaces[1], PSCi1.inTransition[1]) annotation( - Line(points = {{-22, -64}, {-39, -64}, {-39, -46}, {-56, -46}, {-56, -30}}, thickness = 0.5)); - annotation( - uses(PNlib(version = "3.0.0")), - Diagram(graphics = {Text(origin = {-337, -14}, extent = {{3, 0}, {-3, 0}}, textString = "text"), Text(origin = {-115, -90}, extent = {{3, 0}, {-3, 0}}, textString = "text"), Text(origin = {-304, 192}, extent = {{42, -20}, {-42, 0}}, textString = "Station subnet"), Rectangle(origin = {-245, 103}, lineColor = {0, 0, 255}, lineThickness = 0.5, extent = {{-103, 71}, {103, -71}}), Rectangle(origin = {-257, 5}, lineColor = {0, 255, 0}, lineThickness = 0.5, extent = {{-91, 23}, {91, -23}}), Text(origin = {-304, -20}, extent = {{42, -20}, {-42, 0}}, textString = "User demand subnet"), Rectangle(origin = {224, 30}, lineColor = {0, 170, 255}, lineThickness = 0.5, extent = {{-132, 72}, {132, -72}}), Text(origin = {121, 136}, extent = {{57, -48}, {-57, 0}}, textString = "User Demand (park) subnet"), Polygon(origin = {342, 55}, lineColor = {255, 85, 255}, lineThickness = 0.5, points = {{-154, 111}, {-154, 57}, {32, 57}, {32, -139}, {142, -139}, {142, 137}, {-154, 137}, {-154, 127}, {-154, 111}}), Text(origin = {273, 201}, extent = {{-81, 25}, {81, -25}}, textString = "Car Maintenance (Center) subnet"), Rectangle(origin = {293, -77}, lineColor = {85, 85, 0}, lineThickness = 0.5, extent = {{-145, 87}, {145, -87}}), Text(origin = {227, -176}, extent = {{-73, 20}, {73, -20}}, textString = "Car-Sharing Park (Center) subnet"), Text(extent = {{-16, 40}, {-16, 40}}, textString = "text"), Text(origin = {-20, 48}, extent = {{-26, 16}, {26, -16}}, textString = "Cars in use"), Text(origin = {-339, 67}, extent = {{-37, 35}, {37, -35}}, textString = "Charging of cars"), Text(origin = {-204, 63}, extent = {{-32, 7}, {32, -7}}, textString = "Cars are ready")}, coordinateSystem(extent = {{-380, 240}, {500, -200}})), - version = ""); -<<<<<<< HEAD -end CarSharing; -======= -end CarSharingSystem; ->>>>>>> origin/master diff --git a/CarSharingSystem.png b/CarSharingSystem.png deleted file mode 100644 index dd926395ead42c0985ed75efecc1c95cae11cb30..0000000000000000000000000000000000000000 Binary files a/CarSharingSystem.png and /dev/null differ diff --git a/CarSharingSystemCaseStudy.mo b/CarSharingSystemCaseStudy.mo index 8d00bf911a59af7605504f722136b025a9026833..a5ce42c3be77df7d04c99dbd5f7eac5120323e82 100644 --- a/CarSharingSystemCaseStudy.mo +++ b/CarSharingSystemCaseStudy.mo @@ -1,25 +1,23 @@ model CarSharingSystemCaseStudy - // Parameters - parameter Integer numCars = 10 "Number of cars in the system"; - parameter Integer numUsers = 1 "Number of users in the system"; + parameter Integer numCars = 10 "Number of cars in the system at starting point"; + parameter Integer numUsers = 1 "Number of users in the system at starting point"; parameter Real userArrivalRate = 1.0 "User arrival rate (users per time unit)"; parameter Real returnRate = 0.5 "Car return rate"; parameter Real chargingTime = 1.0 "Time to fully charge a car"; parameter Real usageTime = 1.0 "Car usage time by a customer"; parameter Real userPatience = 10.0 "Maximum waiting time for users"; - // State variables for objectives - Real totalWaitingTime(start=0) "Total waiting time for users"; - Real totalCarsRented(start=0) "Total number of cars rented"; - discrete Integer usersLeaving(start=0); - + Real totalWaitingTime(start = 0) "Total waiting time for users"; + Real totalCarsRented(start = 0) "Total number of cars rented"; + Real totalChargingTime(start = 0) "Total charging time for all cars"; + discrete Integer usersLeaving(start = 0); // Discrete Place: Number of free places in the station PNlib.Components.PD PSCii(nIn = 1, nOut = 1) annotation( - Placement(transformation(origin = {-306, 90}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); + Placement(transformation(origin = {-328, 90}, extent = {{-10, -10}, {10, 10}}, rotation = -90))); // Stochastic Transition: Car is ready and available for users after charging operation PNlib.Components.TES TCRi(nIn = 1, nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/chargingTime) annotation( - Placement(transformation(origin = {-278, 54}, extent = {{-10, -10}, {10, 10}}))); + Placement(transformation(origin = {-280, 16}, extent = {{-10, -10}, {10, 10}}))); // Discrete Place: Cars parked at the station, ready and then available for users PNlib.Components.PD PSRi(nIn = 1, nOut = 1, startTokens = numCars) annotation( Placement(transformation(origin = {-242, 82}, extent = {{-10, -10}, {10, 10}}))); @@ -28,31 +26,31 @@ model CarSharingSystemCaseStudy Placement(transformation(origin = {-240, 116}, extent = {{10, -10}, {-10, 10}}))); // Immediate Transition: User demand "satisfied" and then "user departure" from station PNlib.Components.T TUSi(nIn = 2, nOut = 2) annotation( - Placement(transformation(origin = {-202, 82}, extent = {{-14, -14}, {14, 14}}))); + Placement(transformation(origin = {-180, 82}, extent = {{-14, -14}, {14, 14}}))); // Discrete Place: Car in use by customers - PNlib.Components.PD PCU(nIn = 2, nOut = 3, startTokens = 0) annotation( - Placement(transformation(origin = {1, 23}, extent = {{21, -21}, {-21, 21}}, rotation = -90))); - // Discrete Place: Users waiting -during a given random delay- for available and ready cars in the station + PNlib.Components.PD PCU(nIn = 2, nOut = 3, startTokens = 5) annotation( + Placement(transformation(origin = {1, 17}, extent = {{21, -21}, {-21, 21}}, rotation = -90))); + // Discrete Place: Users waiting during a given random delay- for available and ready cars in the station PNlib.Components.PD PSDi(nIn = 1, nOut = 2, startTokens = numUsers) annotation( - Placement(transformation(origin = {-270, 10}, extent = {{-10, -10}, {10, 10}}))); + Placement(transformation(origin = {-268, -90}, extent = {{-10, -10}, {10, 10}}))); // Deterministic transition: User demand “not satisfied” at station PNlib.Components.TD TUNi(nIn = 1, delay = userPatience) annotation( - Placement(transformation(origin = {-180, 10}, extent = {{-10, -10}, {10, 10}}))); + Placement(transformation(origin = {-178, -90}, extent = {{-10, -10}, {10, 10}}))); // Stochastic Transition: User demand arrival at station PNlib.Components.TES TUDi(nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/userArrivalRate) annotation( - Placement(transformation(origin = {-314, 10}, extent = {{-10, -10}, {10, 10}}))); - // Stochastic Transition: Car return to station Si by user. Then, the car is in a charging situation + Placement(transformation(origin = {-312, -90}, extent = {{-10, -10}, {10, 10}}))); + // Stochastic Transition: Car return to station by user. Then, the car is in a charging situation PNlib.Components.TES TCCi(nIn = 2, nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/chargingTime) annotation( - Placement(transformation(origin = {-288, 144}, extent = {{10, -10}, {-10, 10}}))); + Placement(transformation(origin = {-316, 126}, extent = {{10, -10}, {-10, 10}}))); // Stochastic Transition: Car picked up for “long” maintenance (e.g. due to an incident/ accident) by service provider PNlib.Components.TES TCM(nIn = 1, nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/chargingTime) annotation( - Placement(transformation(origin = {216, 142}, extent = {{-10, -10}, {10, 10}}))); - // Discrete Place: Cars under maintainance + Placement(transformation(origin = {222, 160}, extent = {{-10, -10}, {10, 10}}))); + // Discrete Place: Cars under maintenance PNlib.Components.PD PCM(nIn = 1, nOut = 1, startTokens = 2) annotation( - Placement(transformation(origin = {382, 178}, extent = {{-10, -10}, {10, 10}}))); + Placement(transformation(origin = {384, 160}, extent = {{-10, -10}, {10, 10}}))); // Stochastic Transition: After maintenance, car is parked at the station Park. It is ready and available for users PNlib.Components.TES TMPR(nIn = 1, nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/usageTime) annotation( - Placement(transformation(origin = {384, 74}, extent = {{-10, -10}, {10, 10}}))); + Placement(transformation(origin = {468, 74}, extent = {{-10, -10}, {10, 10}}))); // Discrete Place: Car in use by customers PNlib.Components.PD PCU_1(nIn = 2, nOut = 1, startTokens = 3) annotation( Placement(transformation(origin = {392, -8}, extent = {{10, -10}, {-10, 10}}))); @@ -61,89 +59,90 @@ model CarSharingSystemCaseStudy Placement(transformation(origin = {342, -94}, extent = {{-10, -10}, {10, 10}}))); // Discrete Place: Car in use by customers PNlib.Components.PD PCU_2(nIn = 1, nOut = 1, startTokens = 1) annotation( - Placement(transformation(origin = {252, -130}, extent = {{-10, -10}, {10, 10}}))); + Placement(transformation(origin = {296, -130}, extent = {{-10, -10}, {10, 10}}))); // Stochastic transition: Car return to station Park by user. This car will be in charging operation PNlib.Components.TES TCPc(nIn = 1, nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/usageTime) annotation( - Placement(transformation(origin = {166, -92}, extent = {{-10, -10}, {10, 10}}))); + Placement(transformation(origin = {186, -92}, extent = {{-10, -10}, {10, 10}}))); // Immediate Transition: User demand “satisfied” and then “user departure” from station park PNlib.Components.T TUSp(nIn = 2, nOut = 1) annotation( - Placement(transformation(origin = {117, -7}, extent = {{21, -21}, {-21, 21}}))); + Placement(transformation(origin = {113, -7}, extent = {{21, -21}, {-21, 21}}))); // Stochastic Transition: User demand arrival at station park PNlib.Components.TES TUDp(nIn = 0, nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/userPatience) annotation( - Placement(transformation(origin = {336, 72}, extent = {{10, -10}, {-10, 10}}))); + Placement(transformation(origin = {336, 74}, extent = {{10, -10}, {-10, 10}}))); // Helper transition PNlib.Components.PD P1(nIn = 1, nOut = 2) annotation( - Placement(transformation(origin = {278, 74}, extent = {{10, -10}, {-10, 10}}))); + Placement(transformation(origin = {280, 74}, extent = {{10, -10}, {-10, 10}}))); // Stochastic Transition: User demand “not satisfied” at Park. The user leaves the station without having been served PNlib.Components.TDS TUNp(nIn = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/userPatience) annotation( - Placement(transformation(origin = {144, 82}, extent = {{10, -10}, {-10, 10}}))); - + Placement(transformation(origin = {144, 74}, extent = {{10, -10}, {-10, 10}}))); inner PNlib.Components.Settings settings(showTokenFlow = true) annotation( Placement(transformation(origin = {-356, 208}, extent = {{-10, -10}, {10, 10}}))); - equation - // Update total waiting time when users leave + // Calculate total waiting time when users leave when change(PSDi.tokenFlow.outflow[2]) then - usersLeaving = PSDi.tokenFlow.outflow[2]; // Number of users leaving - totalWaitingTime = pre(totalWaitingTime) + usersLeaving * userPatience; + usersLeaving = PSDi.tokenFlow.outflow[2]; + // Number of users leaving + totalWaitingTime = pre(totalWaitingTime) + usersLeaving*userPatience; end when; - - // Update total number of cars rented + // Calculate total number of cars rented when change(PSRi.tokenFlow.outflow[1]) then totalCarsRented = PSRi.tokenFlow.outflow[1]; end when; - + // Calculate total charging time + when TCCi.active then + totalChargingTime = pre(totalChargingTime) + chargingTime; + end when; // Connections connect(TUDi.outPlaces, PSDi.inTransition) annotation( - Line(points = {{-309.2, 10}, {-279.2, 10}}, thickness = 0.5)); + Line(points = {{-307.2, -90}, {-277.2, -90}}, thickness = 0.5)); connect(PSRi.outTransition[1], TUSi.inPlaces[1]) annotation( - Line(points = {{-231.2, 82}, {-207.2, 82}}, thickness = 0.5)); + Line(points = {{-231.2, 82}, {-187, 82}}, thickness = 0.5)); connect(PSDi.outTransition[1], TUSi.inPlaces[2]) annotation( - Line(points = {{-259.2, 10}, {-213.2, 10}, {-213.2, 82}, {-207.2, 82}}, thickness = 0.5)); + Line(points = {{-257, -90}, {-213.2, -90}, {-213.2, 82}, {-187, 82}}, thickness = 0.5)); connect(PSDi.outTransition[2], TUNi.inPlaces[1]) annotation( - Line(points = {{-259.2, 10}, {-183.2, 10}}, thickness = 0.5)); + Line(points = {{-257.2, -90}, {-181.2, -90}}, thickness = 0.5)); connect(PSCi.outTransition[1], TCCi.inPlaces[1]) annotation( - Line(points = {{-250.8, 116}, {-267, 116}, {-267, 144}, {-283, 144}}, thickness = 0.5)); + Line(points = {{-250.8, 116}, {-267, 116}, {-267, 126}, {-311, 126}}, thickness = 0.5)); connect(TCCi.outPlaces[1], PSCii.inTransition[1]) annotation( - Line(points = {{-293, 144}, {-308.8, 144}, {-308.8, 100}, {-306.6, 100}}, thickness = 0.5)); + Line(points = {{-321, 126}, {-328.8, 126}, {-328.8, 101}, {-328, 101}}, thickness = 0.5)); connect(PSCii.outTransition[1], TCRi.inPlaces[1]) annotation( - Line(points = {{-306, 79.2}, {-282, 79.2}, {-282, 53.2}}, thickness = 0.5)); + Line(points = {{-328, 79}, {-328, 16}, {-285, 16}}, thickness = 0.5)); connect(TCRi.outPlaces[1], PSRi.inTransition[1]) annotation( - Line(points = {{-273.2, 54}, {-251.2, 54}, {-251.2, 82}}, thickness = 0.5)); + Line(points = {{-275, 16}, {-275, 82}, {-251.2, 82}}, thickness = 0.5)); connect(TCM.outPlaces[1], PCM.inTransition[1]) annotation( - Line(points = {{221, 142}, {261, 142}, {261, 178}, {371, 178}}, thickness = 0.5)); + Line(points = {{227, 160}, {373, 160}}, thickness = 0.5)); connect(PCM.outTransition[1], TMPR.inPlaces[1]) annotation( - Line(points = {{393, 178}, {407, 178}, {407, 80.5}, {379, 80.5}, {379, 74}}, thickness = 0.5)); + Line(points = {{395, 160}, {449, 160}, {449, 73.5215}, {463, 73.5215}, {463, 74}}, thickness = 0.5)); connect(TMPR.outPlaces[1], PCU_1.inTransition[1]) annotation( - Line(points = {{389, 74}, {450, 74}, {450, -8}, {403, -8}}, thickness = 0.5)); + Line(points = {{473, 74}, {450, 74}, {450, -8}, {403, -8}}, thickness = 0.5)); connect(TCPR.outPlaces[1], PCU_1.inTransition[2]) annotation( Line(points = {{347, -94}, {347, -51}, {403, -51}, {403, -8}}, thickness = 0.5)); connect(PCU_2.outTransition[1], TCPR.inPlaces[1]) annotation( - Line(points = {{263, -130}, {337, -130}, {337, -94}}, thickness = 0.5)); + Line(points = {{307, -130}, {323, -130}, {323, -94}, {337, -94}}, thickness = 0.5)); connect(TCPc.outPlaces[1], PCU_2.inTransition[1]) annotation( - Line(points = {{171, -92}, {241, -92}, {241, -130}}, thickness = 0.5)); + Line(points = {{191, -92}, {241, -92}, {241, -130}, {285, -130}}, thickness = 0.5)); connect(PCU_1.outTransition[1], TUSp.inPlaces[1]) annotation( - Line(points = {{381, -8}, {127, -8}, {127, -7}}, thickness = 0.5)); + Line(points = {{381, -8}, {123, -8}, {123, -7}}, thickness = 0.5)); connect(TUDp.outPlaces[1], P1.inTransition[1]) annotation( - Line(points = {{331, 72}, {326, 72}, {326, 74}, {289, 74}}, thickness = 0.5)); + Line(points = {{331, 74}, {291, 74}}, thickness = 0.5)); connect(P1.outTransition[1], TUNp.inPlaces[1]) annotation( - Line(points = {{267, 74}, {149, 74}, {149, 82}}, thickness = 0.5)); + Line(points = {{269, 74}, {149, 74}}, thickness = 0.5)); connect(P1.outTransition[2], TUSp.inPlaces[2]) annotation( - Line(points = {{267, 74}, {242, 74}, {242, 22}, {127, 22}, {127, -7}}, thickness = 0.5)); + Line(points = {{269, 74}, {266, 74}, {266, 22}, {123, 22}, {123, -7}}, thickness = 0.5)); connect(PCU.outTransition[1], TCCi.inPlaces[2]) annotation( - Line(points = {{2, 46}, {-141, 46}, {-141, 142}, {-172, 142}, {-172, 145}, {-284, 145}, {-284, 144}}, thickness = 0.5)); + Line(points = {{1, 40}, {2.25, 40}, {2.25, 140}, {-102, 140}, {-102, 139}, {-105, 139}, {-105, 139.25}, {-279, 139.25}, {-279, 131.312}, {-311, 131.312}, {-311, 126}}, thickness = 0.5)); connect(PCU.outTransition[2], TCM.inPlaces[1]) annotation( - Line(points = {{2, 46}, {107, 46}, {107, 140}, {12, 140}, {12, 93}, {212, 93}, {212, 142}}, thickness = 0.5)); + Line(points = {{1, 40}, {108, 40}, {108, 95}, {199, 95}, {199, 160.812}, {217, 160.812}, {217, 160}}, thickness = 0.5)); connect(PCU.outTransition[3], TCPc.inPlaces[1]) annotation( - Line(points = {{2, 46}, {162, 46}, {162, -92}}, thickness = 0.5)); + Line(points = {{1, 40}, {163, 40}, {163, -92}, {181, -92}}, thickness = 0.5)); connect(TUSi.outPlaces[1], PCU.inTransition[1]) annotation( - Line(points = {{-196, 82}, {2, 82}, {2, 0}}, thickness = 0.5)); + Line(points = {{-173, 82}, {-100, 82}, {-100, -48}, {0.5, -48}, {0.5, -6}, {1, -6}}, thickness = 0.5)); connect(TUSi.outPlaces[2], PSCi.inTransition[1]) annotation( - Line(points = {{-196, 82}, {-157, 82}, {-157, 116}, {-230, 116}}, thickness = 0.5)); + Line(points = {{-173, 82}, {-157, 82}, {-157, 116}, {-230, 116}}, thickness = 0.5)); connect(TUSp.outPlaces[1], PCU.inTransition[2]) annotation( - Line(points = {{106, -6}, {2, -6}, {2, 0}}, thickness = 0.5)); + Line(points = {{103, -7}, {53.5, -7}, {53.5, -6}, {1, -6}}, thickness = 0.5)); annotation( uses(PNlib(version = "3.0.0"), Modelica(version = "4.0.0")), - Diagram(graphics = {Text(origin = {-337, -14}, extent = {{3, 0}, {-3, 0}}, textString = "text"), Text(origin = {-304, 192}, extent = {{42, -20}, {-42, 0}}, textString = "Station subnet"), Rectangle(origin = {-245, 103}, lineColor = {0, 0, 255}, lineThickness = 0.5, extent = {{-103, 71}, {103, -71}}), Rectangle(origin = {-257, 5}, lineColor = {0, 255, 0}, lineThickness = 0.5, extent = {{-91, 23}, {91, -23}}), Text(origin = {-304, -20}, extent = {{42, -20}, {-42, 0}}, textString = "User demand subnet"), Rectangle(origin = {224, 30}, lineColor = {0, 170, 255}, lineThickness = 0.5, extent = {{-132, 72}, {132, -72}}), Text(origin = {121, 136}, extent = {{57, -48}, {-57, 0}}, textString = "User Demand (park) subnet"), Polygon(origin = {342, 55}, lineColor = {255, 85, 255}, lineThickness = 0.5, points = {{-154, 111}, {-154, 57}, {32, 57}, {32, -139}, {142, -139}, {142, 137}, {-154, 137}, {-154, 127}, {-154, 111}}), Text(origin = {273, 201}, extent = {{-81, 25}, {81, -25}}, textString = "Car Maintenance (Center) subnet"), Rectangle(origin = {293, -77}, lineColor = {85, 85, 0}, lineThickness = 0.5, extent = {{-145, 87}, {145, -87}}), Text(origin = {227, -176}, extent = {{-73, 20}, {73, -20}}, textString = "Car-Sharing Park (Center) subnet"), Text(extent = {{-16, 40}, {-16, 40}}, textString = "text"), Text(origin = {-38, 62}, extent = {{-26, 16}, {26, -16}}, textString = "Cars in use"), Text(origin = {-339, 67}, extent = {{-37, 35}, {37, -35}}, textString = "Charging of cars"), Text(origin = {-204, 63}, extent = {{-32, 7}, {32, -7}}, textString = "Cars are ready")}, coordinateSystem(extent = {{-380, 240}, {500, -200}})), + Diagram(graphics = {Text(origin = {-335, -114}, extent = {{3, 0}, {-3, 0}}, textString = "text"), Text(origin = {-310, 194}, extent = {{42, -20}, {-42, 0}}, textString = "Station subnet", fontSize = 12, fontName = "Open Sans"), Rectangle(origin = {-244, 77}, lineColor = {0, 0, 255}, lineThickness = 0.5, extent = {{-104, 97}, {104, -97}}), Rectangle(origin = {-244, -90}, lineColor = {0, 255, 0}, lineThickness = 0.5, extent = {{-104, 30}, {104, -30}}), Text(origin = {-293, -132}, extent = {{55, -6}, {-55, 0}}, textString = "User demand subnet", fontSize = 12, fontName = "Open Sans"), Rectangle(origin = {227, 31}, lineColor = {0, 170, 255}, lineThickness = 0.5, extent = {{-135, 71}, {135, -71}}), Text(origin = {113, 140}, extent = {{85, -54}, {-85, 0}}, textString = "User Demand (park) subnet", fontSize = 12, fontName = "Open Sans"), Polygon(origin = {342, 55}, lineColor = {255, 85, 255}, lineThickness = 0.5, points = {{-154, 111}, {-154, 57}, {32, 57}, {32, -139}, {142, -139}, {142, 137}, {-154, 137}, {-154, 127}, {-154, 111}}), Text(origin = {273, 204}, extent = {{-117, 26}, {117, -26}}, textString = "Car Maintenance (Center) subnet", fontSize = 12, fontName = "Open Sans"), Rectangle(origin = {293, -77}, lineColor = {85, 85, 0}, lineThickness = 0.5, extent = {{-145, 87}, {145, -87}}), Text(origin = {232, -176}, extent = {{-92, 20}, {92, -20}}, textString = "Car-Sharing Park (Center) subnet", fontSize = 12, fontName = "Open Sans"), Text(extent = {{-16, 40}, {-16, 40}}, textString = "text")}, coordinateSystem(extent = {{-380, 240}, {500, -200}})), version = ""); end CarSharingSystemCaseStudy; diff --git a/PN4ECSS.JPG b/PN4ECSS.JPG deleted file mode 100644 index 32b340e0d057f79888276d81ca66191ab9108411..0000000000000000000000000000000000000000 Binary files a/PN4ECSS.JPG and /dev/null differ diff --git a/PN4ECSS.gif b/PN4ECSS.gif deleted file mode 100644 index e6010768f4e27d5e3baa35c5df336fbb61d89119..0000000000000000000000000000000000000000 Binary files a/PN4ECSS.gif and /dev/null differ diff --git a/README.md b/README.md index 38335fd9fc652d6206bdc2c8ed91110df080ff42..7ac78fb4a98e6814f909c925ad66b79b8471293c 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,25 @@ Petri Net for Electric Car-Sharing System (ECSS). -## Background +## Introduction -Implementation of the ECSS Petri Net model described in [this paper](https://www.e3s-conferences.org/articles/e3sconf/abs/2020/30/e3sconf_evf2020_03001/e3sconf_evf2020_03001.html) (shown as below) in Modelica. +Implementation and modification of the ECSS Petri Net model in Modelica based on [this paper](https://www.e3s-conferences.org/articles/e3sconf/abs/2020/30/e3sconf_evf2020_03001/e3sconf_evf2020_03001.html). - +Three **objective functions** have been implemented: +* `totalWaitingTime`: Calculate the total waiting time of users +* `totalChargingTime`: Calculate the total charging time of cars + +* `CarsRented`: Calculate the rented cars in total + +In an optimization problem, `totalWaitingTime` and `totalChargingTime` need to be minimized, `CarsRented` needs to be maximized. + +## Demo + +Modeling Electric Car-sharing Systems with Petri nets using Modelica and Optimization using MOO4Modelica + +https://youtu.be/LOc7q_BexsY ## Environments @@ -18,33 +30,40 @@ Implementation of the ECSS Petri Net model described in [this paper](https://www ## Model Description -The implementation implemented "The City" subnets, but only two of them (left part), for some simplicity. + + +#### 1. Station Subnet + +* TCCi: Car return to the station and then in a charging situation. +* PSCi: Number of free places in the station. +* TCRi: Car is ready and available for users after charging operation. +* PSRi: Cars parked at the station, ready and then available for users. +* TUSi: User demand "satisfied" and then "user departure" from station. +* PCU: Car in use. -The "Commercial and Industrial Center" subnets has been also implemented (right part). +#### 2. User Demand Subnet -With this model my computer runs already very slow 😑 +* TUDi: User demand arrival at station. +* PSDi: Users waiting during a given random delay- for available and ready cars in the station. +* TUNi: User demand “not satisfied”, user leaves. -There are two Modelica models +#### 3. Car-sharing Park (Center) Subnet -* `CarSharing.mo` is the model of a subnet of "The City" part. -* `CarSharingSystem.mo` is the model of the whole ECSS system. +* TCPc: Car return to station Park by user. This car will be in charging operation. +* TCPR: The car is ready and available for other users, after its charging operation. - +#### 4. User Demand (Park) Subnet -This model generates some stochastic user (demands), you can simulate: +* TUNp: User demand “not satisfied” at park. User leaves. -* how many cars are in use, -* how many cars are charging thus not available, -* how many cars finished charging and are ready for being rent, -* how many users don't have a car available so they just leave, -* etc. +* TUDp: User demand arrival at station park. +* TUSp: User demand “satisfied” and then “user departure” from station park -Here you will find a gif to visualize the simulation result. +#### 5. Car Maintenance (Center) Subnet -<<<<<<< HEAD - -======= - +* TCM: Car picked up for “long” maintenance (e.g. due to an incident/ accident) by service provider +* PCM: Cars under maintenance +* TMPR: After maintenance, car is parked at the station Park. It is ready and available for users ## How Tokens are Generated and Flow Through the Model diff --git a/assets/CarSharingSystemCaseStudy.png b/assets/CarSharingSystemCaseStudy.png new file mode 100644 index 0000000000000000000000000000000000000000..5abb8196bcbffa5c77802b10a512dbaa3879329d Binary files /dev/null and b/assets/CarSharingSystemCaseStudy.png differ