Commit 9dcb4ca0 authored by Jakob Schöttl's avatar Jakob Schöttl
Browse files

Simplify model according to data

passengers are indifferent in two of these 3 cases.
in the third case, there is too few data anyway.
parent 73190583
......@@ -17,9 +17,7 @@ import org.vadere.simulator.models.seating.trainmodel.SeatGroup;
import org.vadere.simulator.models.seating.trainmodel.TrainModel;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.AttributesSeating;
import org.vadere.state.attributes.models.seating.SeatFacingDirection;
import org.vadere.state.attributes.models.seating.SeatRelativePosition;
import org.vadere.state.attributes.models.seating.SeatSide;
import org.vadere.state.attributes.models.seating.model.SeatPosition;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.Agent;
......@@ -256,24 +254,7 @@ public class SeatingModel implements ActiveCallback, Model {
}
private Seat chooseSeat2(final SeatGroup seatGroup) {
if (seatGroup.onlySideChoice()) {
// choice only between window/aisle
final EnumeratedDistribution<SeatSide> distribution =
new EnumeratedDistribution<>(rng, attributes.getSeatChoice2Side());
SeatSide side = distribution.sample();
return seatGroup.availableSeatAtSide(side);
} else if (seatGroup.onlyFacingDirectionChoice()) {
// choice only between forward/backward
final EnumeratedDistribution<SeatFacingDirection> distribution =
new EnumeratedDistribution<>(rng, attributes.getSeatChoice2FacingDirection());
SeatFacingDirection facingDirection = distribution.sample();
return seatGroup.availableSeatAtFacingDirection(facingDirection);
} else {
// choice between both window/aisle and forward/backward
return seatGroup.getTheTwoAvailableSeats().get(random.nextInt(2));
}
return seatGroup.getTheTwoAvailableSeats().get(random.nextInt(2));
}
private Seat chooseSeat3(final SeatGroup seatGroup) {
......
......@@ -11,9 +11,7 @@ import org.vadere.simulator.models.seating.trainmodel.Seat;
import org.vadere.simulator.models.seating.trainmodel.SeatGroup;
import org.vadere.simulator.models.seating.trainmodel.TrainModel;
import org.vadere.state.attributes.models.AttributesSeating;
import org.vadere.state.attributes.models.seating.SeatFacingDirection;
import org.vadere.state.attributes.models.seating.SeatRelativePosition;
import org.vadere.state.attributes.models.seating.SeatSide;
import org.vadere.state.attributes.models.seating.model.SeatPosition;
import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.Pedestrian;
......@@ -80,34 +78,6 @@ public class TestChooseSeat {
}
}
@StatisticalTestCase
@Test
public void testChooseSeat2OnlySideChoice() {
final int nTrials = 1000;
fillSeatGroup(seatGroup, 0, 1);
final TallySheet<Seat> tallySheet = runChooseSeat(nTrials);
final Seat seat = seatGroup.getSeat(2); // window seat
Map<SeatSide, Double> map = FractionProbabilityNormalization.normalize(new AttributesSeating().getSeatChoice2Side());
assertEquals(map.get(SeatSide.WINDOW),
(double) tallySheet.getCount(seat) / nTrials, 0.05);
}
@StatisticalTestCase
@Test
public void testChooseSeat2OnlyDirectionChoice() {
final int nTrials = 1000;
fillSeatGroup(seatGroup, 0, 2);
final TallySheet<Seat> tallySheet = runChooseSeat(nTrials);
final Seat seat = seatGroup.getSeat(3); // forward facing seat
Map<SeatFacingDirection, Double> map = FractionProbabilityNormalization.normalize(new AttributesSeating().getSeatChoice2FacingDirection());
assertEquals(map.get(SeatFacingDirection.FORWARD),
(double) tallySheet.getCount(seat) / nTrials, 0.05);
}
@StatisticalTestCase
@Test
public void testChooseSeat2Both() {
......
......@@ -6,9 +6,7 @@ import java.util.stream.Collectors;
import org.apache.commons.math3.util.Pair;
import org.vadere.state.attributes.Attributes;
import org.vadere.state.attributes.models.seating.SeatFacingDirection;
import org.vadere.state.attributes.models.seating.SeatRelativePosition;
import org.vadere.state.attributes.models.seating.SeatSide;
import org.vadere.state.attributes.models.seating.ValueWithProbabilityFraction;
import org.vadere.state.attributes.models.seating.model.SeatPosition;
import org.vadere.state.scenario.Et423Geometry;
......@@ -32,10 +30,6 @@ public class AttributesSeating extends Attributes {
private List<ValueWithProbabilityFraction<SeatRelativePosition>> seatChoice1;
private List<ValueWithProbabilityFraction<SeatSide>> seatChoice2Side;
private List<ValueWithProbabilityFraction<SeatFacingDirection>> seatChoice2FacingDirection;
{
// initialize fields with values from data collection
// TODO make this autogenerated
......@@ -55,14 +49,6 @@ public class AttributesSeating extends Attributes {
addFraction(seatChoice1, SeatRelativePosition.ACROSS, 14);
addFraction(seatChoice1, SeatRelativePosition.NEXT, 5);
seatChoice2Side = new ArrayList<>(2);
addFraction(seatChoice2Side, SeatSide.AISLE, 4);
addFraction(seatChoice2Side, SeatSide.WINDOW, 4);
seatChoice2FacingDirection = new ArrayList<>(2);
addFraction(seatChoice2FacingDirection, SeatFacingDirection.FORWARD, 7);
addFraction(seatChoice2FacingDirection, SeatFacingDirection.BACKWARD, 6);
}
public String getTrainGeometry() {
......@@ -81,14 +67,6 @@ public class AttributesSeating extends Attributes {
return toPairListForEnumeratedDistribution(seatChoice1);
}
public List<Pair<SeatSide, Double>> getSeatChoice2Side() {
return toPairListForEnumeratedDistribution(seatChoice2Side);
}
public List<Pair<SeatFacingDirection, Double>> getSeatChoice2FacingDirection() {
return toPairListForEnumeratedDistribution(seatChoice2FacingDirection);
}
public static <T> List<Pair<T, Double>> toPairListForEnumeratedDistribution(
List<ValueWithProbabilityFraction<T>> list) {
return list.stream().map(ValueWithProbabilityFraction::toPair).collect(Collectors.toList());
......
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