Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PN4ECSS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zizhe Wang
PN4ECSS
Commits
5fa613c7
Commit
5fa613c7
authored
11 months ago
by
Zizhe Wang
Browse files
Options
Downloads
Patches
Plain Diff
update model for orchestration workflow
parent
6c4732b6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CarSharingSystemCaseStudy.mo
+19
-29
19 additions, 29 deletions
CarSharingSystemCaseStudy.mo
with
19 additions
and
29 deletions
CarSharingSystem
Simplified
.mo
→
CarSharingSystem
CaseStudy
.mo
+
19
−
29
View file @
5fa613c7
model CarSharingSystemSimplified
model CarSharingSystemCaseStudy
// Parameters
// Parameters
parameter Integer numCars = 10 "Number of cars in the system";
parameter Integer numCars = 10 "Number of cars in the system";
parameter Integer numUsers = 5 "Number of users in the system";
parameter Integer numUsers = 1 "Number of users in the system";
parameter Real userArrivalRate = 1.0 "User arrival rate (users per time unit)";
parameter Real returnRate = 0.5 "Car return rate";
parameter Real returnRate = 0.5 "Car return rate";
parameter Real chargingTime = 1.0 "Time to fully charge a car";
parameter Real chargingTime = 1.0 "Time to fully charge a car";
parameter Real usageTime = 1.0 "Car usage time by a customer";
parameter Real usageTime = 1.0 "Car usage time by a customer";
parameter Real userPatience =
2
.0 "Maximum waiting time for users";
parameter Real userPatience =
10
.0 "Maximum waiting time for users";
// State variables for objectives
// State variables for objectives
Real totalWaitingTime(start=0) "Total waiting time for users";
Real totalWaitingTime(start=0) "Total waiting time for users";
Real carUtilization(start=0) "Car utilization over time";
Real totalCarsRented(start=0) "Total number of cars rented";
Real carsInUse(start=0) "Number of cars in use";
discrete Integer usersLeaving(start=0);
// Discrete Variables for Intermediate Calculations
discrete Real waitingTimeIncrement(start=0);
discrete Real carUtilizationIncrement(start=0);
// Discrete Place: Number of free places in the station
// Discrete Place: Number of free places in the station
PNlib.Components.PD PSCii(nIn = 1, nOut = 1) annotation(
PNlib.Components.PD PSCii(nIn = 1, nOut = 1) annotation(
...
@@ -38,10 +36,10 @@ model CarSharingSystemSimplified
...
@@ -38,10 +36,10 @@ model CarSharingSystemSimplified
PNlib.Components.PD PSDi(nIn = 1, nOut = 2, startTokens = numUsers) annotation(
PNlib.Components.PD PSDi(nIn = 1, nOut = 2, startTokens = numUsers) annotation(
Placement(transformation(origin = {-270, 10}, extent = {{-10, -10}, {10, 10}})));
Placement(transformation(origin = {-270, 10}, extent = {{-10, -10}, {10, 10}})));
// Deterministic transition: User demand “not satisfied” at station
// Deterministic transition: User demand “not satisfied” at station
PNlib.Components.TD TUNi(nIn = 1) annotation(
PNlib.Components.TD TUNi(nIn = 1
, delay = userPatience
) annotation(
Placement(transformation(origin = {-180, 10}, extent = {{-10, -10}, {10, 10}})));
Placement(transformation(origin = {-180, 10}, extent = {{-10, -10}, {10, 10}})));
// Stochastic Transition: User demand arrival at station
// Stochastic Transition: User demand arrival at station
PNlib.Components.TES TUDi(nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/user
Patienc
e) annotation(
PNlib.Components.TES TUDi(nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/user
ArrivalRat
e) annotation(
Placement(transformation(origin = {-314, 10}, extent = {{-10, -10}, {10, 10}})));
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
// Stochastic Transition: Car return to station Si 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(
PNlib.Components.TES TCCi(nIn = 2, nOut = 1, distributionType = PNlib.Types.DistributionType.Exponential, h = 1/chargingTime) annotation(
...
@@ -84,23 +82,15 @@ model CarSharingSystemSimplified
...
@@ -84,23 +82,15 @@ model CarSharingSystemSimplified
Placement(transformation(origin = {-356, 208}, extent = {{-10, -10}, {10, 10}})));
Placement(transformation(origin = {-356, 208}, extent = {{-10, -10}, {10, 10}})));
equation
equation
// Objective Equations
// Update total waiting time when users leave
// totalWaitingTime = numUsers * userPatience * (1 - returnRate); // Total waiting time is number of users multiplied by their patience
when change(PSDi.tokenFlow.outflow[2]) then
// carUtilization = (numUsers * usageTime) / (numCars * (usageTime + chargingTime + (1 / returnRate))); // Car utilization is based on usage time
usersLeaving = PSDi.tokenFlow.outflow[2]; // Number of users leaving
totalWaitingTime = pre(totalWaitingTime) + usersLeaving * userPatience;
// Objective Equations
// Calculate waiting time when users leave without getting a car
when change(PSDi.t) then
waitingTimeIncrement = (pre(PSDi.t) - PSDi.t) * userPatience;
totalWaitingTime = pre(totalWaitingTime) + waitingTimeIncrement;
end when;
end when;
// Calculate car utilization
// Update total number of cars rented
when change(PSRi.t) then
when change(PSRi.tokenFlow.outflow[1]) then
carsInUse = numCars - PSRi.t;
totalCarsRented = PSRi.tokenFlow.outflow[1];
carUtilizationIncrement = carsInUse * usageTime / (numCars * (time + Modelica.Constants.eps));
carUtilization = pre(carUtilization) + carUtilizationIncrement;
end when;
end when;
// Connections
// Connections
...
@@ -153,7 +143,7 @@ equation
...
@@ -153,7 +143,7 @@ equation
connect(TUSp.outPlaces[1], PCU.inTransition[2]) annotation(
connect(TUSp.outPlaces[1], PCU.inTransition[2]) annotation(
Line(points = {{106, -6}, {2, -6}, {2, 0}}, thickness = 0.5));
Line(points = {{106, -6}, {2, -6}, {2, 0}}, thickness = 0.5));
annotation(
annotation(
uses(PNlib(version = "3.0.0")),
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 = {-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}})),
version = "");
version = "");
end CarSharingSystem
Simplified
;
end CarSharingSystem
CaseStudy
;
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment