Vehicle Routing drop visit demand if hard score goes to negative #1342
sharmas1ddharth
started this conversation in
General
Replies: 1 comment 7 replies
-
For example, on your vehicle class: @planning_entity
class Vehicle:
orders: Annotated[list[Order], PlanningListVariable(allows_unassigned_values=True)]
... on your order class, there should be a @planning_entity
class Order:
vehicle: Annotated[Vehicle | None, InverseRelationShadowVariable(source_variable_name='orders')]
... and in your constraint provider def unassigned_order(constraint_factory: ConstraintFactory) -> Constraint:
return (constraint_factory.for_each_including_unassigned(Order)
.filter(lambda order: order.vehicle is None)
.penalize(HardMediumSoftScore.ONE_MEDIUM)
.as_constraint("Unassigned Order")
) You will need to change the score type in your |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am developing a Vehicle Routing application using timefold and want to drop visit demand if my constraint hard score go to negative, for example my vehicle capacity is 5 and I have total 8 orders my constraint is vehicle capacity with hard score penalize , currently timefold will assign all 8 orders to that vehicle but with negative hard score, how to achieve that timefold will drop some demands to make score positive
Beta Was this translation helpful? Give feedback.
All reactions