我是OptaPlanner的新手。我遇到了一些商品的取货和送货问题,这些商品必须以有效的方式在城市的不同车站之间重新分配。每个站点的最大总容量(假设每个项目消耗一个单位的容量)。
为此,我正在扩展TWVRP,尝试创建一个将位置映射到客户列表(反之亦然)的Station类,以便我可以跟踪该位置所有客户的供求总量,以及那里还有多少容量。我将站点列表添加到VehicleRoutingSolution中,如下所示:
@ProblemFactCollectionProperty
public List<Station> getStationList() {
return stationList;
}
public void setStationList(List<Station> stationList) {
this.stationList = stationList;
}
该站本身的相关代码如下:
@XStreamAlias("VrpStation")
@DeepPlanningClone
@PlanningEntity
public class Station extends AbstractPersistable {
protected Location location;
protected List<Customer> customers;
protected Integer capacity;
protected Map<WareType, Integer> current;
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public List<Customer> getCustomers() {
return customers;
}
public void setCustomers(List<Customer> customers) {
this.customers = customers;
}
public Integer getCapacity() {
return capacity;
}
public void setCapacity(Integer capacity) {
this.capacity = capacity;
}
public Map<WareType, Integer> getCurrentWares() {
Map<WareType, Integer> current = new HashMap<WareType, Integer>();
for (Customer customer : getCustomers()) {
for (WareType wt: customer.getCurrent().keySet()) {
int old = current.containsKey(wt) ? current.get(wt) : 0;
current.put(wt, old + customer.getCurrent().get(wt));
}
}
return current;
}
}
我还向客户添加了对该站点的引用。
@PlanningEntity
@XStreamAlias("VrpCustomer")
@XStreamInclude({
TimeWindowedCustomer.class
})
public class Customer extends AbstractPersistable implements Standstill {
protected Station station;
public Station getStation() {
return station;
}
public void setStation(Station station) {
this.station = station;
}
@Override
public Location getLocation() {
return getStation().getLocation();
}
// ... same old same old
}
已对其进行设置,以便每个客户都可以请求或要求一种类型的商品。工作站本身不会更改,但是客户当然会更改,因此@DeepPlanningClone注释。
但是,当我使用这些调整来运行optaplanner示例时,我似乎正在获得针对我的解决方案从未访问过的客户的更新。我怀疑这与车站及其客户的克隆方式有关,但是我不确定确切的问题是什么或如何解决。我在做什么错了?