Commit 18673bbf authored by THEBAULT Antoine's avatar THEBAULT Antoine
Browse files

correct successor clocks of transitions in trajectory nets

parent a1ef76bb
Pipeline #329250 passed with stages
in 13 minutes and 43 seconds
EqualizationNet.EquNetNeuralMov
EqualizationNet.EquNetV2Mov
% Equalization net
% A simple circular network with 30 stations
% Total distance = 20km
......@@ -13,7 +13,7 @@ EqualizationNet.EquNetNeuralMov
%neuralNet:50:50tokens/4.nnet
%neuralNet:10tokens/5.nnet
%neuralNet:15tokens/2.nnet
%neuralNet:6-multiTokensNbSantiago/30tokens/3.nnet
neuralNet:6-multiTokensNbSantiago/30tokens/3.nnet
%neuralNet:35tokens/4.nnet
%neuralNet:5tokens/1bis.nnet
%neuralNet:50tokens/2.nnet
......@@ -26,7 +26,7 @@ beta:0
ALPHA:1
MIN_HEADWAY_DISTANCE:30
MAX_SPEED:600
MIN_SPEED:0:%400:%was 260
MIN_SPEED:260:%400:%was 260
RANGE_NOISE:0
place:1:p1:666
......
TrajectoryNet
place:1:p1:1000:100
place:2:p2:1000:100
place:3:p3:1000:100
place:4:p4:1000:100
place:5:p5:1000:100
transition:1:t1:[5,10]
transition:2:t2:[5,10]
transition:3:t3:[5,10]
transition:4:t4:[20,100]
transition:5:t5:[5,10]
inflow:1:1
outflow:1:2
inflow:2:2
outflow:2:3
inflow:3:3
outflow:3:4
inflow:4:4
outflow:4:5
inflow:5:5
outflow:5:1
initial:1:2:3
%weibull law with a high coeficient
%Weibull:30
%trajectory:4:0,1000,50,600:50,600,100,50:100,50,200,0
\ No newline at end of file
......@@ -105,9 +105,9 @@ public class TrajTransition extends TransitionAbstract{
if (!presetMarked(m1)) {
return true;
}
if (this == t) {
/*if (this == t) {
return true;
}
}*/
}
return false;
}
......
......@@ -76,6 +76,18 @@ public class Trajectory {
}
return null;
}
/**return the absciss of the y value on the trajectory*/
public Float absciss(float y) {
// browse the segments of the trajectory
for (Segment segment : segments) {
if (segment.belongToImage(y)) {
segment.calculFunction();
return (y - segment.getBeta())/segment.getAlpha();
}
}
return (float) 0;
}
/**
* create a new Trajectory object based on the current Trajectory with new
......@@ -373,4 +385,8 @@ public class Trajectory {
}
return -1;
}
float getClock() {
return this.absciss(0);
}
}
......@@ -33,13 +33,13 @@ public class TrajectoryNet extends PhysicalModel {
Unblocked unblocked = new Unblocked();// the pair of unblocked trajectories of places
HashMap<Integer, Float> config = new HashMap<>();// associate a transition number and its clock
Sampler s = new Sampler();
//String fname;
// String fname;
Logger logger = Logger.getLogger("logger");
Sampler sampler = new Sampler();
boolean weibull = false;
boolean gaussian = false;
int weibullCoef = 5;
int n = 1;//the number of fired transitions
int n = 1;// the number of fired transitions
public TrajectoryNet(String fname) {
this.fname = fname;
......@@ -128,7 +128,7 @@ public class TrajectoryNet extends PhysicalModel {
int nb = Integer.parseInt(segments[1]);
BooleanPlace booleanPlace = new BooleanPlace(nb, segments[2]);
booleanPlaces.put(nb, booleanPlace);
//currentMarking.add(booleanPlace);
// currentMarking.add(booleanPlace);
} else if (segments[0].equals("transition")) {// transition:nb:name:[min,max]
int nb = Integer.parseInt(segments[1]);
TrajTransition transition;
......@@ -144,8 +144,8 @@ public class TrajectoryNet extends PhysicalModel {
}
transitions.put(nb, transition);
} else if (segments[0].equals("trajectory")) {// trajectory:placeNb:x1,y1,x2,y2:x2,y2,x3,y3 an id and the
int placeNb = Integer.parseInt(segments[1]); // points of its segments separated by :
Trajectory trajectory = new Trajectory();
int placeNb = Integer.parseInt(segments[1]); // points of its segments separated by :
Trajectory trajectory = new Trajectory();
for (int i = 2; i < segments.length; i++) {
String[] points = segments[i].split(",");
float x0 = Float.parseFloat(points[0]);
......@@ -158,7 +158,7 @@ public class TrajectoryNet extends PhysicalModel {
TrajPlace place = places.get(placeNb);
place.addTrajectory(trajectory);
currentMarking.add(place);
} else if (segments[0].equals("inflow")) {
int trans = Integer.parseInt(segments[1]);
int place = Integer.parseInt(segments[2]);
......@@ -184,10 +184,10 @@ public class TrajectoryNet extends PhysicalModel {
weibullCoef = Integer.valueOf(segments[1]);
logs += "Law of Weibull";
}
}catch (NumberFormatException nfe) {
logs += "error net line "+lineNb+" : a value is not a number\n";
}catch (Exception e) {
logs += "error in the net file at line "+lineNb+"\n";
} catch (NumberFormatException nfe) {
logs += "error net line " + lineNb + " : a value is not a number\n";
} catch (Exception e) {
logs += "error in the net file at line " + lineNb + "\n";
e.printStackTrace();
}
for (TrajTransition t : this.transitions.values()) {
......@@ -350,7 +350,8 @@ public class TrajectoryNet extends PhysicalModel {
if (t.busyPostSet()) {
this.blocked.put(t.number, t);
System.out.println("Transition " + t.name + "blocked");
} else if (t.controlAllowsFiring() && t.pre.usableTrajectory() != null && t.post.availableForNewPlace()) {
} else if (t.controlAllowsFiring() && t.pre.usableTrajectory() != null
&& t.post.availableForNewPlace()) {
fireable.put(t.number, t);
System.out.println("Transition " + t.name + "firable");
} else if (t.pre.trajectories.size() > 0) {// t.presetMarked(currentMarking)) {
......@@ -365,7 +366,7 @@ public class TrajectoryNet extends PhysicalModel {
fireable.put(t.getNumber(), t);
}
}
/*
* for (TrajTransition t : transitions.values()) { if (t.pre.usableTrajectory()
* != null && t.clock != null && t.clock == 0 && t.post.availableForNewPlace())
......@@ -398,8 +399,8 @@ public class TrajectoryNet extends PhysicalModel {
enabled = new HashMap<>();
blocked = new HashMap<>();
fireable = new HashMap<>();
n=1; //the number of the step set to 1, used for the logs
n = 1; // the number of the step set to 1, used for the logs
if (init)
currentMarking = initMarking.copy();
......@@ -433,8 +434,8 @@ public class TrajectoryNet extends PhysicalModel {
}
public boolean discreteMove(String pathLogs, long elapsedTime, boolean enableLogs) {
stepsNb ++;
nbDiscreteSteps ++;
stepsNb++;
nbDiscreteSteps++;
discreteStep = true;
// fire a transition t
Random rand = new Random();
......@@ -453,8 +454,8 @@ public class TrajectoryNet extends PhysicalModel {
System.out.println("Removing" + p.getName() + "from marking");
if (!p.removeTrajectory())
System.out.println("can't remove trajectory");
if (p.trajectories.isEmpty())
tempMarking.remove(p);
// if (p.trajectories.isEmpty())
System.out.println("remove marking : " + p.getName() + " : " + tempMarking.remove(p));
if (t.controlPre != null)
t.controlPre.value = false;
......@@ -467,7 +468,7 @@ public class TrajectoryNet extends PhysicalModel {
System.out.println("Adding" + p.getName() + "to temp marking");
newMarking.add(p);
p.createTrajectory(sampler);
/*** log the fired transition **********/
/*** nline : date : fired transition ***/
if (enableLogs) {
......@@ -505,6 +506,16 @@ public class TrajectoryNet extends PhysicalModel {
}
}
// if the new marking still contains a place with a trajectory in the previous
// place of the fired
// transition
if (newMarking.contains(t.pre)) {
float clock = t.pre.trajectories.get(0).getClock();
System.out.println("clock : " + clock);
t.clock = clock;
this.config.put(t.number, clock);
}
this.enabled = new HashMap<>();
this.blocked = new HashMap<>();
this.fireable = new HashMap();
......@@ -520,7 +531,8 @@ public class TrajectoryNet extends PhysicalModel {
this.blocked.put(et.number, et);
System.out.println(et.name + "blocked");
} else if (et.controlAllowsFiring() && et.pre.usableTrajectory() != null && et.post.availableForNewPlace()) {
} else if (et.controlAllowsFiring() && et.pre.usableTrajectory() != null
&& et.post.availableForNewPlace()) {
this.fireable.put(et.number, et);
System.out.println(et.name + "firable");
} else {
......@@ -599,7 +611,7 @@ public class TrajectoryNet extends PhysicalModel {
@Override
public String discreteMove(TransitionAbstract onet, String logFile, float currentTime, boolean enableLogs) {
stepsNb ++;
stepsNb++;
nbDiscreteSteps++;
discreteStep = true;
// fire a transition t
......@@ -616,8 +628,8 @@ public class TrajectoryNet extends PhysicalModel {
System.out.println("Removing" + p.getName() + "from marking");
if (!p.removeTrajectory())
System.out.println("can't remove trajectory");
if (p.trajectories.isEmpty())
tempMarking.remove(p);
// if (p.trajectories.isEmpty())
tempMarking.remove(p);
if (t.controlPre != null)
t.controlPre.value = false;
......@@ -630,7 +642,7 @@ public class TrajectoryNet extends PhysicalModel {
System.out.println("Adding" + p.getName() + "to temp marking");
newMarking.add(p);
p.createTrajectory(sampler);
/*** log the fired transition **********/
/*** nline : date : fired transition ***/
if (enableLogs) {
......@@ -668,6 +680,16 @@ public class TrajectoryNet extends PhysicalModel {
}
}
// if the new marking still contains a place with a trajectory in the previous
// place of the fired
// transition
if (newMarking.contains(t.pre)) {
float clock = t.pre.trajectories.get(0).getClock();
System.out.println("clock : " + clock);
t.clock = clock;
this.config.put(t.number, clock);
}
this.enabled = new HashMap<>();
this.blocked = new HashMap<>();
this.fireable = new HashMap();
......@@ -683,7 +705,8 @@ public class TrajectoryNet extends PhysicalModel {
this.blocked.put(et.number, et);
System.out.println(et.name + "blocked");
} else if (et.controlAllowsFiring() && et.pre.usableTrajectory() != null && et.post.availableForNewPlace()) {
} else if (et.controlAllowsFiring() && et.pre.usableTrajectory() != null
&& et.post.availableForNewPlace()) {
this.fireable.put(et.number, et);
System.out.println(et.name + "firable");
} else {
......@@ -735,7 +758,7 @@ public class TrajectoryNet extends PhysicalModel {
@Override
public TransitionAbstract findTransition(String string) {
for (TrajTransition t : transitions.values()) {
if(t.getName().equals(string))
if (t.getName().equals(string))
return t;
}
return null;
......
file;time elapsed;speed;time elapsed+ beta * |target speed - average speed|; runs out of target; speedAfterEqu
2021-10-27 140838.87;112,83525;434,25238;112,83525;0;562,07947
2021-10-27 140839.289;112,26518;434,1276;112,26518;0;585,6447
2021-10-27 140839.706;111,21018;441,30246;111,21018;0;569,9531
2021-10-27 140840.133;111,180466;433,95865;111,180466;0;588,21326
2021-10-27 140840.449;110,36037;436,4381;110,36037;0;579,7234
2021-10-27 140842.398;109,98722;433,38193;109,98722;0;577,9115
2021-10-27 140843.104;109,78456;435,57272;109,78456;0;560,3382
2021-10-27 140845.124;108,51841;431,27988;108,51841;0;582,32556
2021-10-27 140845.814;108,483864;436,25284;108,483864;0;587,68256
2021-10-27 140847.608;108,28711;431,1983;108,28711;0;583,3621
2021-10-27 140854.266;108,234634;422,47238;108,234634;0;564,47925
2021-10-27 140854.764;106,75258;434,40225;106,75258;0;583,9874
2021-10-27 140854.966;106,09425;429,68286;106,09425;0;577,3904
2021-10-27 140855.647;105,8405;431,84982;105,8405;0;572,7127
2021-10-27 140856.802;105,08927;432,7474;105,08927;0;580,5335
2021-10-27 140857.879;104,54845;436,06085;104,54845;0;584,80945
2021-10-27 140858.28;103,98788;425,092;103,98788;0;581,6648
2021-10-27 140903.757;103,639915;434,30157;103,639915;0;577,3497
2021-10-27 140909.487;103,62772;436,8396;103,62772;0;575,37067
2021-10-27 140909.871;103,35426;428,23953;103,35426;0;565,8804
2021-10-27 140916.137;103,00482;437,74362;103,00482;0;571,7144
2021-10-27 140917.452;102,93717;432,6253;102,93717;0;566,3259
2021-10-27 140917.556;102,918175;431,95587;102,918175;0;585,51953
2021-10-27 140924.284;102,343506;432,54922;102,343506;0;573,1311
2021-10-27 140927.802;102,065414;433,37396;102,065414;0;580,53656
2021-10-27 140928.085;101,86855;429,76047;101,86855;0;561,11017
2021-10-27 140928.554;101,82722;429,7121;101,82722;0;570,10925
2021-10-27 140928.929;101,81458;428,35132;101,81458;0;568,88654
2021-10-27 140929.313;101,155075;428,0969;101,155075;0;578,8804
2021-10-27 140929.513;101,1165;423,6517;101,1165;0;572,9997
2021-10-27 140938.468;99,23579;420,68002;99,23579;0;574,32654
2021-10-27 140939.686;97,605354;425,10056;97,605354;0;561,1352
2021-10-27 140939.78;97,19016;420,20535;97,19016;0;574,19763
2021-10-27 140939.969;94,99324;416,70038;94,99324;0;570,24896
file;time elapsed;average speed;outOfTargetNb;;speedAfterEqu
......@@ -486,6 +486,15 @@ public class StartController implements Initializable {
});
contextMenu.getItems().add(clear);
logsText.setContextMenu(contextMenu);
/** clear the stats pane with a right click/clear menu */
ContextMenu contextMenu2 = new ContextMenu();
MenuItem clear2 = new MenuItem("Clear");
clear2.setOnAction(e -> {
statsTextString.set("");
});
contextMenu2.getItems().add(clear2);
statsText.setContextMenu(contextMenu2);
stepsEqualizationButton.setVisible(false);
targetEqualization.setVisible(false);
......
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