private Integer calculatePreviousDepartureTime(Customer customer) { Standstill previousStandstill = customer.getPreviousStandstill(); Integer departureTime; if (previousStandstill instanceof Customer) { departureTime = ((Customer) previousStandstill).getDepartureTime(); } else if (previousStandstill instanceof Vehicle) { // el mayor entre la hora de apertura del depósito y la hora de // inicio de operación del vehículo // logger.trace("antes de obtener readyTime de vehiculo!!!"); departureTime = Integer.valueOf( Math.max( ((Vehicle) previousStandstill).getDepot().getReadyTime(), ((Vehicle) previousStandstill).getReadyTime())); } else { // si no ha sido asignado entonces el departureTime es null para que // calcule un arrivalTime igual al readyTime // (para no romper una restriccion dura) departureTime = null; } return departureTime; }
protected void updateArrivalTimeAndEnfOfTrip(ScoreDirector scoreDirector, Customer customer) { // updateChain(scoreDirector, customer); // return; logger.trace( "--------------------------------------------------------------------------------"); logger.trace( "-----------------updateArrivalTimeAndEnfOfTrip begins---------------------------"); logger.trace( "--------------------------------------------------------------------------------"); // customer.getPreviousStandstill()==null // customer.getNextCustomer()==null // customer.getVehicle().getNextCustomer()==null logger.trace("customer : " + customer); logger.trace("customer.getPreviousStandstill() : " + customer.getPreviousStandstill()); logger.trace("customer.getNextCustomer() : " + customer.getNextCustomer()); logger.trace("customer.getVehicleRecursive(): " + customer.getVehicleRecursive()); logger.debug("vehicle.getNextCustomer(): " + customer.getVehicleRecursive().getNextCustomer()); updateArrivalTime(scoreDirector, customer); Vehicle vehicle = customer.getVehicleRecursive(); Integer calculatedEndOfTrip = calculateEndOfTrip(vehicle); // if(calculatedEndOfTrip==1 && customer.getPreviousStandstill()!=null) // { // logger.debug("customer : " + customer); // logger.debug("customer.getPreviousStandstill() : " + customer.getPreviousStandstill()); // logger.debug("customer.getNextCustomer() : " + customer.getNextCustomer()); // logger.debug("customer.getVehicleRecursive(): " + customer.getVehicleRecursive()); // logger.debug("vehicle.getNextCustomer(): " + // customer.getVehicleRecursive().getNextCustomer()); // } vehicle.setEndOfTrip(calculatedEndOfTrip); // while(vehicle!=null) // { // updateArrivalTime(scoreDirector, customer); // vehicle.setEndOfTrip(calculateEndOfTrip(vehicle)); // // vehicle = vehicle.getNextVehicle(); // } // logger.trace(" while (nextVehicle != null)..."); // logger.trace("vehicle: " + vehicle); // logger.trace("nextVehicle: " + nextVehicle); // logger.trace("nextVehicle.getReadyTime(): " + nextVehicle.getReadyTime()); // logger.trace("calculatedEndOfTrip: " + calculatedEndOfTrip); // logger.trace("nextVehicle.getNextCustomer(): " + nextVehicle.getNextCustomer()); // updateArrivalTime(scoreDirector, customer); // Vehicle vehicle = customer.getVehicleRecursive(); // // Integer calculatedEndOfTrip = calculateEndOfTrip(vehicle); // vehicle.setEndOfTrip(calculatedEndOfTrip); // // Vehicle nextVehicle = vehicle.getNextVehicle(); // // while (nextVehicle != null) // { // // // nextVehicle.setReadyTime(calculatedEndOfTrip); // if (nextVehicle.getNextCustomer() != null) { // updateArrivalTime(scoreDirector, nextVehicle.getNextCustomer()); // // } // calculatedEndOfTrip = calculateEndOfTrip(nextVehicle); // nextVehicle.setEndOfTrip(calculatedEndOfTrip); // // vehicle = nextVehicle; // nextVehicle = vehicle.getNextVehicle(); // calculatedEndOfTrip = calculateEndOfTrip(vehicle); // // } logger.trace( "--------------------------------------------------------------------------------"); logger.trace( "-----------------updateArrivalTimeAndEnfOfTrip ends-----------------------------"); logger.trace( "--------------------------------------------------------------------------------"); }