Reputation: 47
For Vehicle Routing problem, I removed the interface (i.e. Standstill) and modified Solver Configuration (i.e. vehicleRoutingSolverConfig.xml) to replace Standstill entityClass with Vehicle entityClass. Also made other changes to the code.
However, I get the following exception while trying to run the Solver.
Exception in thread "main" java.lang.IllegalArgumentException: The entityClass (class org.optaplanner.examples.vehiclerouting.domain.Customer) has a PlanningVariable annotated property (previousVehicle) with chained (true) and propertyType (class org.optaplanner.examples.vehiclerouting.domain.Vehicle) which is not a superclass/interface of or the same as the entityClass (class org.optaplanner.examples.vehiclerouting.domain.Customer).
I'm trying to understand, why optaPlanner requires chain variable (i.e of type Vehicle) referenced in another Entity class (i.e. of type Customer) to have same superclass/interface.
Upvotes: 1
Views: 150
Reputation: 27312
See the docs about chained planning vars. There's a number of build-in specs for chained vars:
Apply those 2 specs and it turns out that entity (such as Customer
) and anchor (such as Vehicle
) need a common interface (such as Standstill
), because otherwise what type would the Entity.getPreviousInChain()
planning variable return? It can be either.
As for the error you're getting: it says that in that model, it's impossible for an entity to point to another entity, so it's impossible to have chains longer than 1 entity...
Upvotes: 3