MAJ terminée. Nous sommes passés en version 14.6.2 . Pour consulter les "releases notes" associées c'est ici :

https://about.gitlab.com/releases/2022/01/11/security-release-gitlab-14-6-2-released/
https://about.gitlab.com/releases/2022/01/04/gitlab-14-6-1-released/

Commit 06fba649 authored by THEBAULT Antoine's avatar THEBAULT Antoine
Browse files

add speed after equal in multiTokensNb data log

parent b7e9a73e
Pipeline #304418 passed with stages
in 4 minutes and 57 seconds
EqualizationNet.EquNetNeuralMov
EqualizationNet.EquNetV2Mov
% Equalization net
% A simple circular network with 30 stations
% Total distance = 20km
% distance in meters and time in minutes, speed in meters by minute
%neuralNet:santiago6inputsSpeedMov.nnet
neuralNet:santiago6inputsSpeedMov.nnet
%neuralNet:1.nnet
%neuralNet:SantiagoNet/5.nnet:%cantons fixes
%neuralNet:linearSantiago4inputsMov.nnet
%neuralNet:santiago4inputsMov.nnet
%neuralNet:santiagoNet2input/2.nnet
%neuralNet:50:50tokens/4.nnet
neuralNet:30tokens/3.nnet
%neuralNet:30tokens/3.nnet
%neuralNet:50tokens/2.nnet
targetSpeed:500
......@@ -299,4 +299,4 @@ outflow:60:60
nitial:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50
nitial:1:2:3:4:5:6:7:8:9:10:11:12:13:14
nitial:1:2:3:4:5
initial:1:2:3:4:5
......@@ -49,8 +49,10 @@ public abstract class EquNet extends PhysicalModel {
float lastTokenSpeed = 0;
float lastTokenTtb = 0;
int nbTokens = 0;
float totalSpeedSum = 0;
int speedSteps = 0;
//float totalSpeedSum = 0;
//int speedSteps = 0;
float elapsedDistanceAvg = 0;//used to get the average speed
float elapsedTimeToGetAvgSpeed = 0;//used to get the average speed
// public abstract void progressTime(Float delta);
// public abstract String discreteMove(TransitionAbstract onet, String logFile,
......@@ -331,8 +333,10 @@ public abstract class EquNet extends PhysicalModel {
}
timeElapsed = 0;
nbDiscreteSteps = 0;
totalSpeedSum = 0;
speedSteps = 0;
//totalSpeedSum = 0;
//speedSteps = 0;
elapsedDistanceAvg = 0;
elapsedTimeToGetAvgSpeed = 0;
}
@Override
......@@ -461,6 +465,16 @@ public abstract class EquNet extends PhysicalModel {
Collection<EquTransition> values = fireable.values();
return new ArrayList<>(values);
}
//return the avg speed, can be reset with resetSpeedData()
public float getAvgSpeed () {
if (elapsedTimeToGetAvgSpeed == 0)
return 0;
return elapsedDistanceAvg/elapsedTimeToGetAvgSpeed;
/*if (this.speedSteps != 0)
return this.totalSpeedSum/this.speedSteps;
return 0;*/
}
@Override
public HashMap<Integer, ? extends TransitionAbstract> getEnabled() {
......@@ -547,10 +561,6 @@ public abstract class EquNet extends PhysicalModel {
return sum / nb;
}
//the average speed for each time a speed is set for a token (!=0)
//to be overrided
public float getAvgSpeed() {return 0;};
public void insertToken() throws NullGarageException {// insert a new token in the net at the garage place
Token token = new Token();
try {
......@@ -617,4 +627,9 @@ public abstract class EquNet extends PhysicalModel {
}
}
/**used to reset the speed*/
public void resetSpeedData () {
elapsedDistanceAvg = 0;
elapsedTimeToGetAvgSpeed = 0;
}
}
......@@ -35,8 +35,6 @@ public abstract class EquNetNeural extends EquNet {
NeuralNetwork nnet = new MultiLayerPerceptron(TransferFunctionType.TANH, 2, 10, 10, 10, 1);
String nnetPath = null;
float totalSpeedSum = 0;
int speedSteps = 0;
//targetSpeed and beta are used in statsAndTask.OptimizeNeuralNetTask in the MochyUi project
int targetSpeed = 500;
float beta = 0;
......@@ -268,18 +266,18 @@ public abstract class EquNetNeural extends EquNet {
}
}
@Override
/*@Override
public float getAvgSpeed () {
if (this.speedSteps != 0)
return this.totalSpeedSum/this.speedSteps;
//if (this.speedSteps != 0)
//return this.totalSpeedSum/this.speedSteps;
return 0;
}
}*/
@Override
public void reset(boolean value) {
super.reset(value);
this.totalSpeedSum = 0;
this.speedSteps = 0;
//this.totalSpeedSum = 0;
//this.speedSteps = 0;
}
public int getTargetSpeed() {
......
......@@ -117,8 +117,8 @@ public class EquNetNeuralFix extends EquNetNeural {
lastTokenSpeed = token.speed;
lastTokenTtb = token.timeToBrowse;
if (token.speed != 0) {
totalSpeedSum += token.speed;
speedSteps ++;
//totalSpeedSum += token.speed;
//speedSteps ++;
}
// manage the insertion of a new token
......
......@@ -46,12 +46,20 @@ public class EquNetNeuralMov extends EquNetNeural {
stepsNb++;
discreteStep = false;
timeElapsed += delta;
//used to get the elapsedDistanceAvg to get the average speed :
float elapsedDistanceSum = 0;
this.elapsedTimeToGetAvgSpeed += delta;
int moveTokens = 0;
// advance the time for the tokens not at the end of the place
// and not linked to a blocked transition
for (EquPlace p : places.values()) {
if (!p.equals(garage)) {
for (Token token : p.getTokens()) {
if (!token.isAtTheEnd() && !(token.p.distance == 0)) {
elapsedDistanceSum += token.speed * delta;
moveTokens++;
}
// block a token if its successor is in the same place, is blocked and it will
// violates the safety distance rule
// the distance between the token and the position where the headway must be
......@@ -77,6 +85,9 @@ public class EquNetNeuralMov extends EquNetNeural {
}
}
}
//calcul the avg of the elapsed distances
if (moveTokens != 0)
this.elapsedDistanceAvg += elapsedDistanceSum / moveTokens;
// update the enabled, blocked and fireable hashmaps
for (EquPlace p : places.values()) {
for (Token token : p.getTokens()) {
......@@ -163,10 +174,10 @@ public class EquNetNeuralMov extends EquNetNeural {
lastTokenSpeed = token.speed;
lastTokenTtb = token.getTimeToBrowse();
if (token.speed != 0) {
/*if (token.speed != 0) {
totalSpeedSum += token.speed;
speedSteps++;
}
}*/
// manage the insertion of a new token
if (!allowInsertion() && garage.tokens.size() > 0) {
......@@ -192,12 +203,12 @@ public class EquNetNeuralMov extends EquNetNeural {
// " : Speed "
// + token.speed + "\n");
} catch (IOException e) {
logger.log(Level.WARNING, "error of writing in fileLogs in class EquNetV2Mov");
logger.log(Level.WARNING, "error of writing in fileLogs in class EquNetNeuralMov");
} finally {
try {
fileLogs.close();
} catch (IOException e) {
logger.log(Level.WARNING, "error while closing the fileLogs in class EquNetV2Mov");
logger.log(Level.WARNING, "error while closing the fileLogs in class EquNetNeuralMov");
}
}
}
......
......@@ -39,12 +39,20 @@ public class EquNetV2Mov extends EquNet {
stepsNb ++;
discreteStep = false;
timeElapsed += delta;
//used to get the elapsedDistanceAvg to get the average speed:
float elapsedDistanceSum = 0;
elapsedTimeToGetAvgSpeed += delta;
int moveTokens = 0;
// advance the time for the tokens not at the end of the place
// and not linked to a blocked transition
for (EquPlace p : places.values()) {
if (!p.equals(garage)) {
for (Token token : p.getTokens()) {
if (!token.isAtTheEnd() && !(token.p.distance == 0)) {
elapsedDistanceSum += token.speed * delta;
moveTokens++;
}
// block a token if its successor is in the same place, is blocked and it will
// violates the safety distance rule
// the distance between the token and the position where the headway must be
......@@ -70,6 +78,9 @@ public class EquNetV2Mov extends EquNet {
}
}
}
//calcul the avg of the elapsed distances
if (moveTokens != 0)
elapsedDistanceAvg += elapsedDistanceSum / moveTokens;
// update the enabled, blocked and fireable hashmaps
for (EquPlace p : places.values()) {
for (Token token : p.getTokens()) {
......@@ -151,9 +162,9 @@ public class EquNetV2Mov extends EquNet {
lastTokenSpeed = token.speed;
lastTokenTtb = token.timeToBrowse;
if (token.speed != 0) {
totalSpeedSum += token.speed;
speedSteps++;
if (token.p.distance != 0) {
//totalSpeedSum += token.speed;
//speedSteps++;
}
// manage the insertion of a new token
......@@ -335,12 +346,5 @@ public class EquNetV2Mov extends EquNet {
}
return clock;
}
@Override
public float getAvgSpeed () {
if (this.speedSteps != 0)
return this.totalSpeedSum/this.speedSteps;
return 0;
}
}
......@@ -141,6 +141,7 @@ public class MultipleAxesLineChart extends StackPane {
baseChart.setCreateSymbols(false);
baseChart.setLegendVisible(false);
baseChart.getXAxis().setAutoRanging(true);
((NumberAxis) baseChart.getXAxis()).setForceZeroInRange(false);
baseChart.getXAxis().setAnimated(false);
baseChart.getYAxis().setAnimated(false);
}
......@@ -196,6 +197,7 @@ public class MultipleAxesLineChart extends StackPane {
// style x-axis
xAxis.setAutoRanging(true);
xAxis.setForceZeroInRange(false);
xAxis.setVisible(false);
xAxis.setOpacity(0.0); // somehow the upper setVisible does not work
//xAxis.lowerBoundProperty().bind(((NumberAxis) baseChart.getXAxis()).lowerBoundProperty());
......
......@@ -16,6 +16,7 @@ import fr.inria.mochy.ui.LoadFiles;
import fr.inria.mochy.ui.MultipleTokensController;
import fr.inria.mochy.ui.StartController;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
......@@ -56,7 +57,7 @@ public class MultipleTokensNbTask extends AbstractStats {
FileWriter file = null;
file = new FileWriter("logs/data.csv", false);
file.write("tokens nb;average elapsed time;steps average;average speed;over steps nb;min speed\n");
file.write("tokens nb;average elapsed time;steps average;average speed;over steps nb;min speed;standard deviation avg after equalization;speed after equalization\n");
FileWriter cloudDots = null;
cloudDots = new FileWriter("logs/cloudDots.csv", false);
......@@ -105,7 +106,7 @@ public class MultipleTokensNbTask extends AbstractStats {
simu.oneStep();
standardDeviation = n.getStandardDeviation(StartController.getSimu().getPathLogs());
if (n.isDiscreteMove() && n.getLastTokenSpeed() != 0f) {
speedSum += n.getLastTokenSpeed();
//speedSum += n.getLastTokenSpeed();
discreteSteps++;
minSpeed = Math.min(n.getLastTokenSpeed(), minSpeed);
}
......@@ -116,6 +117,7 @@ public class MultipleTokensNbTask extends AbstractStats {
nb++;
stepsSum += steps;
cloudDots.write(i+";"+Float.toString(n.getTimeElapsed()).replace(".", ",")+"\n");
speedSum += n.getAvgSpeed();
} else
overTarget++;
}
......@@ -127,21 +129,30 @@ public class MultipleTokensNbTask extends AbstractStats {
if (nb != 0) {
averageTimeElapsed = timeElapsedSum / nb;
averageNbSteps = stepsSum / nb;
averageSpeed = speedSum / nb;
} else {
averageTimeElapsed = 0;
averageNbSteps = 0;
averageSpeed = 0;
}
if (discreteSteps == 0)
/*if (maxRuns == 0)
averageSpeed = 0;
else
averageSpeed = speedSum / discreteSteps;
averageSpeed = speedSum / maxRuns;*/
/**check the average speed after an equalization*/
StartController.setDisplayChart(false);
float standardDeviationAvg = StartController.launchStepsEqu(10000);
StartController.setDisplayChart(true);
try {
file.write(i + ";" + String.valueOf(averageTimeElapsed).replace(".", ",") + ";"
+ String.valueOf(averageNbSteps).replace(".", ",") + ";"
+ String.valueOf(averageSpeed).replace(".", ",") + ";" + overTarget + ";" +
String.valueOf(minSpeed).replace(".", ",")+"\n");
String.valueOf(minSpeed).replace(".", ",")+";"+
String.valueOf(standardDeviationAvg).replace(".", ",")+";"
+String.valueOf(n.getAvgSpeed()).replace(".", ",")+"\n");
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -202,6 +202,9 @@ public class StartController implements Initializable {
*/
static boolean histogramOpen = false;
/** if set to true, display the chart after the call of launchsteps method */
static boolean displayChart = true;
/** display the current date of the timetable */
static StringProperty dateTTString = new SimpleStringProperty();
@FXML
......@@ -540,13 +543,15 @@ public class StartController implements Initializable {
@FXML
/** load the net file and display its data */
/** The net can be of different type as long as it extends the physical model */
/** Specific methods for loading a particular net are encoded in the net class */
/**
* Specific methods for loading a particular net are encoded in the net class
*/
void loadNet(ActionEvent evt) {
Stage primaryStage = Main.getPrimaryStage();
simu = loadFiles.loadNetFile(primaryStage);
if (simu != null) { // If a simu was created, i.e. a net was correctly loaded
System.out.println("Loaded a " + classModel);
PhysicalModel net = simu.getN();
PhysicalModel net = simu.getN();
displayNet(simu.displayFeedback());
}
}
......@@ -558,42 +563,65 @@ public class StartController implements Initializable {
displayNet(simu.oneStep());
}
public static float launchStepsEqu(int steps) {
int avgStandardDeviation = 0;
int avgSpeed = 0;
int discreteSteps = 0;
int overLimitStdDev = 0;
ArrayList<Float> x = new ArrayList<>();
ArrayList<Float> y = new ArrayList<>();
ArrayList<Float> y2 = new ArrayList<>();
EquNet n = (EquNet) simu.getN();
n.resetSpeedData();
float preAvgSpeed = 0;
int limit = 1;
try {
limit = Integer.parseInt(targetEqualizationValue);
} catch (NumberFormatException e) {
e.printStackTrace();
getLogsTextString().setValue(
"Warning : the field next to steps equalization is not filled with a number (standard deviation limit)");
}
for (int i = 0; i < steps; i++) {
simu.oneStep();
avgStandardDeviation += n.getStandardDeviation("");
if (n.isDiscreteMove() && n.getLastTokenSpeed() != 0) {
avgSpeed += n.getLastTokenSpeed();
discreteSteps++;
}
if (n.getStandardDeviation("") > limit && !n.isDiscreteMove())
overLimitStdDev++;
x.add(n.getTimeElapsed());
y.add(n.getStandardDeviation(""));
if (n.getCurrentAvgSpeed() != 0) {
y2.add(n.getCurrentAvgSpeed());
preAvgSpeed = n.getCurrentAvgSpeed();
} else
y2.add(preAvgSpeed);
}
avgStandardDeviation = avgStandardDeviation / steps;
avgSpeed = avgSpeed / discreteSteps;
statsTextString.setValue("average standard deviation : " + avgStandardDeviation + " - average speed : "
+ n.getAvgSpeed() + " - number of times that the standard deviation " + " is over the limit " + limit
+ " : " + overLimitStdDev + " / " + (steps - discreteSteps) + "timed moves");
if (displayChart)
View.chartEquStandardDeviation(x, y, y2);
return avgStandardDeviation;
}
@FXML
/** perform the number of steps defined in nbSteps */
void launchSteps(ActionEvent evt) {
public void launchSteps(ActionEvent evt) {
int steps = Integer.parseInt(nbSteps.getText());
if (simu != null && classModel.startsWith("EqualizationNet")) {
int avgStandardDeviation = 0;
int avgSpeed = 0;
int discreteSteps = 0;
int overLimitStdDev = 0;
EquNet n = (EquNet) simu.getN();
int limit = 1;
try {
limit = Integer.parseInt(targetEqualization.getText());
} catch (NumberFormatException e) {
e.printStackTrace();
getLogsTextString()
.setValue("Warning : the field next to steps equalization is not filled with a number (standard deviation limit)");
}
for (int i = 0; i < steps; i++) {
simu.oneStep();
avgStandardDeviation += n.getStandardDeviation("");
if (n.isDiscreteMove() && n.getLastTokenSpeed() != 0) {
avgSpeed += n.getLastTokenSpeed();
discreteSteps++;
}
if (n.getStandardDeviation("") > limit && !n.isDiscreteMove())
overLimitStdDev ++;
}
avgStandardDeviation = avgStandardDeviation / steps;
avgSpeed = avgSpeed / discreteSteps;
statsTextString.setValue("average standard deviation : " + avgStandardDeviation +
" - average speed : " + avgSpeed + " - number of times that the standard deviation "+
" is over the limit " + limit + " : " + overLimitStdDev + " / " +
(steps - discreteSteps) + "timed moves");
launchStepsEqu(steps);
} else if (simu != null)
displayNet(simu.main(steps));
simu.main(steps);
displayNet();
}
@FXML
......@@ -614,8 +642,8 @@ public class StartController implements Initializable {
}
FileWriter fileLogs = null;
ArrayList<Float> x = new ArrayList<>();
ArrayList<Float> y = new ArrayList<>();//the standard deviation values
ArrayList<Float> y2 = new ArrayList<>();//the speed values
ArrayList<Float> y = new ArrayList<>();// the standard deviation values
ArrayList<Float> y2 = new ArrayList<>();// the speed values
try {
fileLogs = new FileWriter(simu.getPathLogs().replace("txt", "csv"), false);
......@@ -1844,9 +1872,9 @@ public class StartController implements Initializable {
@FXML
/**
* generate neural nets for EqualizationNet.EquNetNeural nets they are saved in
* the neural folder there is a csv file with the average speed and the
* average timeelapsed of each neural network runs.
* calls stats.GenerateNeuralTask from GenerateNeuralController
* the neural folder there is a csv file with the average speed and the average
* timeelapsed of each neural network runs. calls stats.GenerateNeuralTask from
* GenerateNeuralController
*/
void generateNeuralNets(ActionEvent evt) {
if (classModel.startsWith("EqualizationNet.EquNetNeural"))
......@@ -2261,4 +2289,8 @@ public class StartController implements Initializable {
refreshNet.setValue(value);
}
public static void setDisplayChart(boolean displayChart) {
StartController.displayChart = displayChart;
}
}
......@@ -788,6 +788,8 @@ public class View {
}
}
/**display on a chart the standard deviation as y, the speed as y2 depending of
* the time elapsed x*/
static void chartEquStandardDeviation(ArrayList<Float> x, ArrayList<Float> y, ArrayList<Float> y2) {
Group root = new Group();
Scene scene = new Scene(root, 600, 400);
......@@ -796,6 +798,7 @@ public class View {
final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
xAxis.setLabel("Time");
xAxis.setAutoRanging(true);
yAxis.setLabel("standard deviation");
// creating the chart
final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment