-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from omar753sahl/dev
Model (M/M/C/K) officially done!
- Loading branch information
Showing
9 changed files
with
233 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package models; | ||
|
||
import utils.MathUtils; | ||
import static java.lang.Math.*; | ||
|
||
public class MMCQueueModel extends QueueModel { | ||
@Override | ||
protected PerformanceMetrics calculatePerformanceMetrics(QueueSystemInput inputs) throws QueueModelException { | ||
double lambda = inputs.getArrivalRate(); | ||
double mue = inputs.getServiceRate(); | ||
double c = inputs.getNumberOfServers(); | ||
double r = lambda / mue; | ||
|
||
MathUtils.prepareFact((int) (c + 1)); | ||
|
||
double p0 = calculateP0(c, r); | ||
double Lq = calculateLq(lambda, mue, c, r, p0); | ||
|
||
double Wq = Lq / lambda; | ||
double W = Wq + (1 / mue); | ||
double L = Lq + r; | ||
|
||
return new PerformanceMetrics(L, Lq, W, Wq); | ||
} | ||
|
||
private double calculateLq(double lambda, double mue, double c, double r, double p0) { | ||
double numerator = pow(r, c) * lambda * mue; | ||
double denominator = MathUtils.fact((int) (c - 1)) * pow((c * mue) - lambda, 2); | ||
return (numerator / denominator) * p0; | ||
} | ||
|
||
private double calculateP0(double c, double r) { | ||
double firstTerm = 0; | ||
double secondTerm = ((c * pow(r, c)) / (MathUtils.fact((int) c) * (c - r))); | ||
|
||
for (int n = 0; n <= c - 1; n++) { | ||
firstTerm += (pow(r, n) / MathUtils.fact(n)); | ||
} | ||
|
||
double result = firstTerm + secondTerm; | ||
|
||
return 1 / result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
package ui; | ||
|
||
/** | ||
* Created by Omar | ||
* Date: 18-Dec-17. | ||
*/ | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.input.MouseEvent; | ||
import javafx.scene.layout.BorderPane; | ||
|
||
public class DD1KOutputScreen { | ||
|
||
@FXML | ||
private BorderPane root; | ||
|
||
@FXML | ||
private Label labelL; | ||
|
||
@FXML | ||
private Label labelLq; | ||
|
||
@FXML | ||
private Label labelW; | ||
|
||
@FXML | ||
private Label labelWq; | ||
|
||
@FXML | ||
private Label backButton; | ||
|
||
@FXML | ||
void onBackClicked(MouseEvent event) { | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import java.lang.*?> | ||
<?import java.util.*?> | ||
<?import javafx.scene.*?> | ||
<?import javafx.scene.control.*?> | ||
<?import javafx.scene.layout.*?> | ||
<?import com.jfoenix.controls.JFXRippler?> | ||
<?import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView?> | ||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.ScrollPane?> | ||
<?import javafx.scene.layout.BorderPane?> | ||
<?import javafx.scene.layout.StackPane?> | ||
<?import javafx.scene.layout.VBox?> | ||
<?import javafx.scene.text.Font?> | ||
|
||
<AnchorPane xmlns="http://javafx.com/javafx" | ||
xmlns:fx="http://javafx.com/fxml" | ||
fx:controller="ui.DD1KOutputScreen" | ||
prefHeight="400.0" prefWidth="600.0"> | ||
<BorderPane fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="650.0" prefWidth="394.0" style="-fx-background-color: #252525;" stylesheets="@../css/style_sheet.css" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ui.DD1KOutputScreen"> | ||
<center> | ||
<ScrollPane BorderPane.alignment="CENTER"> | ||
<content> | ||
<VBox alignment="CENTER" nodeOrientation="LEFT_TO_RIGHT" prefHeight="543.0" prefWidth="392.0" spacing="12.0"> | ||
<children> | ||
<Label alignment="CENTER" text="D/D/1/K Performance Metrics" textFill="WHITE"> | ||
<font> | ||
<Font name="Lato Light" size="23.0" /> | ||
</font> | ||
<padding> | ||
<Insets bottom="25.0" /> | ||
</padding> | ||
</Label> | ||
<VBox alignment="CENTER_LEFT"> | ||
<children> | ||
<Label alignment="CENTER" text="N(t)" textFill="WHITE"> | ||
<font> | ||
<Font name="Lato Medium" size="28.0" /> | ||
</font> | ||
</Label> | ||
<Label alignment="CENTER" text="Average number of customers (entities) in the system." textFill="WHITE" wrapText="true"> | ||
<font> | ||
<Font name="Lato Light" size="15.0" /> | ||
</font> | ||
</Label> | ||
<Label fx:id="labelL" layoutX="10.0" layoutY="118.0" text="0.6667" textFill="WHITE"> | ||
<font> | ||
<Font name="Lato Semibold" size="32.0" /> | ||
</font> | ||
</Label> | ||
</children> | ||
</VBox> | ||
<VBox alignment="CENTER_LEFT" layoutX="25.0" layoutY="310.0"> | ||
<children> | ||
<Label alignment="CENTER" text="Wq" textFill="WHITE"> | ||
<font> | ||
<Font name="Lato Medium" size="28.0" /> | ||
</font> | ||
</Label> | ||
<Label alignment="CENTER" text="Average time it takes a customer to start being served." textFill="WHITE" wrapText="true"> | ||
<font> | ||
<Font name="Lato Light" size="15.0" /> | ||
</font> | ||
</Label> | ||
<Label fx:id="labelWq" layoutX="10.0" layoutY="118.0" text="3.3333 " textFill="WHITE"> | ||
<font> | ||
<Font name="Lato Semibold" size="32.0" /> | ||
</font> | ||
</Label> | ||
</children> | ||
</VBox> | ||
</children> | ||
<padding> | ||
<Insets left="40.0" right="40.0" /> | ||
</padding> | ||
</VBox> | ||
</content> | ||
</ScrollPane> | ||
</center> | ||
<top> | ||
|
||
</AnchorPane> | ||
</top> | ||
<top> | ||
<StackPane> | ||
<children> | ||
<JFXRippler styleClass="material_icon_rippler"> | ||
<Label fx:id="backButton" alignment="CENTER" onMouseClicked="#onBackClicked" textAlignment="CENTER" StackPane.alignment="TOP_LEFT"> | ||
<graphic> | ||
<MaterialDesignIconView fill="WHITE" glyphName="ARROW_LEFT" size="32" /> | ||
</graphic> | ||
<padding> | ||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> | ||
</padding> | ||
</Label> | ||
<StackPane.margin> | ||
<Insets left="10.0" right="10.0" top="10.0" /> | ||
</StackPane.margin> | ||
</JFXRippler> | ||
</children> | ||
<BorderPane.margin> | ||
<Insets bottom="10.0" /> | ||
</BorderPane.margin> | ||
</StackPane> | ||
</top> | ||
</BorderPane> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.