我使用OptaPlanner來解決車輛路徑問題的一個變體,其中由車輛服務的客戶的要求差別很大。我有幾個最常見的客戶類型,並希望使用不同的實體類對其進行建模。由於單個驅動程序可以參加不同的類型,因此它們應該能夠形成具有所有類的實例的異構鏈。OptaPlanner與鏈接變量的多個實體類
我試圖通過修改VRP示例來做一個概念驗證。我提取了我的所有客戶的接口ICustomer
,並更改了Standstill
,以便getNextCustomer
返回ICustomer
。 當我嘗試與客戶和顧客2(客戶類的副本),既實現ICustomer運行它,我得到這個錯誤:
Exception in thread "main" java.lang.IllegalArgumentException: The entityClass
(interface org.optaplanner.examples.vehiclerouting.domain.Standstill) has a
InverseRelationShadowVariable annotated property (nextCustomer) with a masterClass
(interface org.optaplanner.examples.vehiclerouting.domain.ICustomer) which is not a
valid planning entity.
在最壞的情況下,我就車型不同客戶類型的枚舉和單個計劃實體中的「ifs」以獲得相同的行爲。不過,知道我是否遇到API限制或者有人知道更好的方法來實現這一點很好。謝謝:)