Skip to content

Commit

Permalink
introduced taxi rides in connect suitability(status)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarrazzo committed Sep 4, 2018
1 parent 8aa10f7 commit d01a914
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
@PlanningEntity
public class Employee extends AbstractPersistable {

private static final int MAX_TAXI_TIME = 240;
private String name;
private Airport homeAirport;

Expand Down Expand Up @@ -67,19 +68,26 @@ public boolean isLastAssignmentArrivingAtHome() {
// TODO allow taking a taxi, but penalize it with a soft score instead
return lastAssignment.getFlight().getArrivalAirport() == homeAirport;
}

public long countInvalidConnections() {
long count = 0L;
public ConnectionStatus getConnectionStatus() {
ConnectionStatus healthCheck = new ConnectionStatus();
FlightAssignment previousAssignment = null;

for (FlightAssignment assignment : flightAssignmentSet) {
if (previousAssignment != null
&& previousAssignment.getFlight().getArrivalAirport()
!= assignment.getFlight().getDepartureAirport()) {
count++;
if (previousAssignment != null) {
Airport previousAirport = previousAssignment.getFlight().getArrivalAirport();
Airport airport = assignment.getFlight().getDepartureAirport();
if (previousAirport != airport) {
Long taxiTimeInMinutes = previousAirport.getTaxiTimeInMinutesTo(airport);
if (taxiTimeInMinutes == null || taxiTimeInMinutes > MAX_TAXI_TIME)
healthCheck.invalidConnection++;
else
healthCheck.taxiMinutes += taxiTimeInMinutes == null ? 0 : taxiTimeInMinutes;
}
}
previousAssignment = assignment;
}
return count;
return healthCheck;
}

public long getFlightDurationTotalInMinutes() {
Expand All @@ -95,6 +103,15 @@ public String toString() {
return name;
}

// ************************************************************************
// Subclasses
// ************************************************************************

public class ConnectionStatus {
public long invalidConnection = 0;
public long taxiMinutes = 0;
}

// ************************************************************************
// Simple getters and setters
// ************************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ end
rule "Transfer between two flights"
when
// TODO FIXME only allow arrival and departure from the same airport (no taxi's)
Employee($count : countInvalidConnections() > 0)
Employee($cs : connectionStatus)
then
scoreHolder.addHardConstraintMatch(kcontext, - $count);
scoreHolder.addMultiConstraintMatch(kcontext, - $cs.invalidConnection, - $cs.taxiMinutes );
end

rule "Employee unavailability"
Expand Down

0 comments on commit d01a914

Please sign in to comment.