2017-09-04 37 views
0
public class VehicleUpdatingVariableListener implements PlanningVariableListener<Customer> {} 

上述類已在7.2 final中刪除。 在我的Optaplanner的實現中,我在updateVehicle裏面寫了片段代碼。VehicleUpdatingVariableListener從版本6.0中的7.2 optaplanner中刪除

protected void updateVehicle(ScoreDirector scoreDirector, Customer sourceCustomer) {} 

當車輛在客戶得到更新所添加的代碼使用,我以前也更新了對方車輛。 對方:增加了一個額外的影子變量。

那麼,我該怎麼做在7.2版本?

編輯1

protected void updateVehicle(ScoreDirector scoreDirector, Customer sourceCustomer) { 
     Standstill previousStandstill = sourceCustomer.getPreviousStandstill(); 
     Vehicle vehicle = previousStandstill == null ? null : previousStandstill.getVehicle(); 
     Customer shadowCustomer = sourceCustomer; 
     while (shadowCustomer != null && shadowCustomer.getVehicle() != vehicle) { 
      scoreDirector.beforeVariableChanged(shadowCustomer, "vehicle"); 
      scoreDirector.beforeVariableChanged(shadowCustomer.getCounterpartCustomer(),"vehicle"); 
      shadowCustomer.setVehicle(vehicle); 
      scoreDirector.afterVariableChanged(shadowCustomer, "vehicle"); 
      scoreDirector.afterVariableChanged(shadowCustomer.getCounterpartCustomer(),"vehicle"); 
      shadowCustomer = shadowCustomer.getNextCustomer(); 
     } 
    } 

回答