title: How to get Optaplanner to select anchor as previousStandstill
body: <p>we are using OptaPlanner for a optimization task similar to the vehicle routing example problem (see <a href="https://docs.optaplanner.org/6.5.0.Final/optaplanner-docs/html_single/index.html#vehicleRouting" rel="nofollow noreferrer">https://docs.optaplanner.org/6.5.0.Final/optaplanner-docs/html_single/index.html#vehicleRouting</a>), but much more complex with a lot more domain knowledge.</p>
  
  <p>Now we have a specific use case where a <em>Vehicle</em>(=anchor of <em>previousStandstill</em> / <em>nextCustomer</em> chain) is new to the planning problem and should get quickly assigned one of e.g. 500 <em>Customers</em>.
  Therefore I would like to use a custom <em>SwapMoveSelectorConfig</em> like this:</p>
  
  <pre><code>    public class VehicleSelectionFilter implements SelectionFilter&lt;Standstill&gt; {
          @Override
          public boolean accept(ScoreDirector scoreDirector, Standstill selection) {
              return selection instanceof Vehicle;
          }
      }
  
      EntitySelectorConfig esc = new EntitySelectorConfig(Standstill.class);
      List&lt;java.lang.Class&lt;? extends SelectionFilter&gt;&gt; selectionFilterClassList = new ArrayList&lt;&gt;();
  
      selectionFilterClassList.add(VehicleSelectionFilter.class);
      esc.setFilterClassList(selectionFilterClassList);
  
      SwapMoveSelectorConfig anchorSwapMoveSelectorConfig = new SwapMoveSelectorConfig();
      anchorSwapMoveSelectorConfig.setEntitySelectorConfig(new EntitySelectorConfig(Customer.class));
      anchorSwapMoveSelectorConfig.setVariableNameIncludeList(Collections.singletonList("previousStandstill"));
      anchorSwapMoveSelectorConfig.setSecondaryEntitySelectorConfig(esc);
      moveSelectorConfigList.add(anchorSwapMoveSelectorConfig);
  </code></pre>
  
  <p>However, this is not a valid constellation due to the different <em>EntitySelector</em> classes (<em>Standstill</em> and <em>Customer</em>):</p>
  
  <p><code>java.lang.IllegalArgumentException: The entitySelector (EntitySelectorConfig(class org.optaplanner.examples.vehiclerouting.domain.Customer))'s entityDescriptor (EntityDescriptor(org.optaplanner.examples.vehiclerouting.domain.Customer)) and secondaryEntitySelectorConfig (EntitySelectorConfig(interface org.optaplanner.examples.vehiclerouting.domain.Standstill))'s entityDescriptor (EntityDescriptor(org.optaplanner.examples.vehiclerouting.domain.Standstill)) must have the same entity class.</code></p>
  
  <p>If I take the same base class <em>Standstill</em>, I cannot access the non-existing member variable <em>previousStandstill</em>.
  <em>nextCustomer</em> also cannot be assigned via <code>anchorSwapMoveSelectorConfig.setVariableNameIncludeList(Collections.singletonList("nextCustomer"));</code>
  due to only being an inverse relation shadow variable.</p>
  
  <p>How can I achieve the desired selectorConfig to force OptaPlanner to try to assign <em>Customers</em> to <em>Vehicles</em> as <em>nextCustomer</em>?</p>
  
  <p>(The general case would be: How to assign a non-anchor planning entity directly to/after an anchor?)</p>