我正在处理带有链式图的VRP路由问题的变体。我实现了一个移动,它在一个链上带有两个实体,但它们本身不是一个子链,并将它们移动到一个新的不同链。这会激活一个GenuineVariableDescriptor,如下所示。
public ChangeVehicleMove(Object entity, GenuineVariableDescriptor variableDescriptor, Object toPlanningValue)
我正在使用此移动来实现自定义MoveListFactory。我在生成GenuineVariableDescriptor时遇到了麻烦。这样做的最佳方式是什么?
移动工厂:
public class ChangeVehicleMoveFactory implements MoveListFactory{
@Override
public List<? extends Move> createMoveList(Solution solution) {
List<Customer> customerList = ((RoutingSolution) solution).getCustomerList();
Iterator<Customer> customerIterator1 = customerList.iterator(), customerIterator2 = customerList.iterator();
List<Move> moveList = new ArrayList<Move>();
Customer customer1, customer2;
Class<?> c = ((RoutingSolution) solution).getCustomerList().getClass();
GenuineVariableDescriptor genuineVariableDescriptor = null;
try {
genuineVariableDescriptor = new GenuineVariableDescriptor(new EntityDescriptor(new SolutionDescriptor(RoutingSolution.class), TimeWindowedCustomer.class), new FieldMemberAccessor(c.getField("previousStandStill")));
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
if (genuineVariableDescriptor != null){
while (customerIterator1.hasNext()) {
while (customerIterator2.hasNext()) {
customer1 = customerIterator1.next();
customer2 = customerIterator2.next();
if (customer1 != customer2 && !customer1.isAssigned())
new ChangeVehicleMove(customer1, genuineVariableDescriptor, customer2);
}
}
}
return null;
}
}
另一种可能性是将移动作为配置中移动列表的一部分。关于这方面的文件很少。如果这条路线是更好的方法,你会如何在配置文件中包含它?