0

Good Afternoon, I want to do a question, i'm working with OptaPlanner and I have problems to build a hard constraint, maybe you could help me; I'm confused, the problem that I'm trying to build is:

  1. I have many trips, and I need to combine in order to use a minimum number of vehicles; the only constraint that I have is that de end of the trip (n) must be less than the start of the next trip (n+1), I make this drl rule but it doesn't work because this only make a group of two trips and a vehicle can make ten trips.

this is my rule

rule "horaInicioFin"

when

   $leftAssignment : Trip(vehiculo!=null, $leftId : hinicio, $carrito : vehiculo);
   $rightAssigment : Trip(vehiculo == $carrito, hinicio>=$leftId, calculateOverlap($leftAssignment, hinicio, idTrip)<0);

then

   scoreHolder.addHardConstraintMatch(kcontext, - 1); 

end

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Do I understand you correctly that you are inserting 1 vehicle and you want the same rule to re-evaluate the same vehicle after assignment? For example Vehicle 1 would go through the rule as long as the calcualteOverlap returns a specific value? Can you update the question with how you instantiate the rule and what facts you would insert? – pandaadb Feb 03 '16 at 15:39
  • you're right when you say that I want to insert a vehicle and this vehicle can do many trips (like the real life), but each trip has to end in order to start de next trip, (the only constraint for my exercise), the rule that I did was based on Nurse example and CloudBalance, but I only get two trips for vehicle, and I can see that is possible to make more trips with a vehicle, I have a vehicle class, trip Class and vehicleTripBalance like cloudBalance, and as you say I want to make a rule that check if the next trip is possible CalculateOverlap – Gabriel Gonzalez Cifuentes Feb 04 '16 at 15:24

0 Answers0