Vehicle Routing Multi Planning Variable Solver configuration

112 views
Skip to first unread message

Marko Bilic

unread,
Mar 10, 2022, 1:58:57 PM3/10/22
to OptaPlanner development
Hey Guys, 

I had a task to integrate Vehicle routing into the current project I am working on but after I wrote the Vehicle routing code and used the base configuration in the VRP example I got some errors saying my planning entity has too many Planning Variables so I started writing my own custom solver config but im running into an error on the previousStandstill planning variable. 

when optaplanner is building the solverconfig I get an error stating:

The minimumCacheType (org.optaplanner.core.impl.heuristic.selector.value.chained.SubChainSelectorFactory@250d440) needs to be based on an EntityIndependentValueSelector (Reinitialize(Initialized(FromSolutionPropertyValueSelector(previousStandstill)))). Check your @ValueRangeProvider annotations.

I followed the documentation here https://docs.optaplanner.org/8.17.0.Final/optaplanner-docs/html_single/#subChainChangeMoveSelector but I keep getting this error, and I wasnt able to find anything online about this error message

the Visit Planning entity(Similar to customer in the example) has 2 additional Planning variables startingTimeGrain and visitDate(its a multi day VRP solution below I provided the configuration I made. Also to note this is the first solver configuration I have ever made so please feel free to point out any issues with the configuration but also if you know how to get rid of this error please let me know.

(hid the package path so ignore the "...")

Solver Config below

 <?xml version="1.0" encoding="UTF-8"?>
<solver xmlns="https://www.optaplanner.org/xsd/solver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.optaplanner.org/xsd/solver https://www.optaplanner.org/xsd/solver/solver.xsd">
<!--<environmentMode>FULL_ASSERT</environmentMode>--><!-- To slowly prove there are no bugs in this code -->
<!--<moveThreadCount>AUTO</moveThreadCount>--><!-- To solve faster by saturating multiple CPU cores -->

<solutionClass>...domain.ScheduleSolution</solutionClass>
<entityClass>...domain.StandStill</entityClass>
<entityClass>...domain.Visit</entityClass>

<scoreDirectorFactory>
                 <constraintProviderClass>...solver.OptimizerConstraintProvider</constraintProviderClass>
   <initializingScoreTrend>ONLY_DOWN</initializingScoreTrend>
</scoreDirectorFactory>

<termination>
   <minutesSpentLimit>5</minutesSpentLimit>
</termination>
<constructionHeuristic>
   <queuedEntityPlacer>
      <entitySelector id="visitEntitySelector">
         <entityClass>...domain.Visit</entityClass>
      </entitySelector>
      <cartesianProductMoveSelector>
         <cacheType>JUST_IN_TIME</cacheType>
         <changeMoveSelector>
            <entitySelector mimicSelectorRef="visitEntitySelector"/>
            <valueSelector variableName="visitDate">
            </valueSelector>
         </changeMoveSelector>
         <changeMoveSelector>
            <entitySelector mimicSelectorRef="visitEntitySelector"/>
            <valueSelector variableName="startingTimeGrain">
               <cacheType>PHASE</cacheType>
            </valueSelector>
         </changeMoveSelector>
         <subChainChangeMoveSelector>
            <entityClass>...domain.Visit</entityClass>
            <subChainSelector>
               <valueSelector variableName="previousStandstill">
               </valueSelector>
            </subChainSelector>
           <valueSelector variableName="previousStandstill">
           </valueSelector>
           <selectReversingMoveToo>true</selectReversingMoveToo>
           </subChainChangeMoveSelector>
           <subChainSwapMoveSelector>
                 <entityClass>...domain.Visit</entityClass>
              <subChainSelector>
                 <valueSelector variableName="previousStandstill">
                    <cacheType>JUST_IN_TIME</cacheType>
                 </valueSelector>
              </subChainSelector>
              <selectReversingMoveToo>true</selectReversingMoveToo>
           </subChainSwapMoveSelector>
        </cartesianProductMoveSelector>
   </queuedEntityPlacer>
</constructionHeuristic>
<localSearch>
   <unionMoveSelector>
      <changeMoveSelector>
         <entitySelector id="visitEntityMoveSelector">
            <entityClass>...domain.Visit</entityClass>
            <cacheType>JUST_IN_TIME</cacheType>
         </entitySelector>
         <valueSelector variableName="visitDate"/>
      </changeMoveSelector>
      <changeMoveSelector>
         <entitySelector mimicSelectorRef="visitEntityMoveSelector" />
         <valueSelector variableName="startingTimeGrain"/>
      </changeMoveSelector>
      <swapMoveSelector/>
         <subChainChangeMoveSelector>
            <entityClass>...domain.Visit</entityClass>
            <subChainSelector>
               <valueSelector variableName="previousStandstill">
               </valueSelector>
           </subChainSelector>
          <valueSelector variableName="previousStandstill">
          </valueSelector>
          <selectReversingMoveToo>true</selectReversingMoveToo>
       </subChainChangeMoveSelector>
       <subChainSwapMoveSelector>
          <entityClass>...domain.Visit</entityClass>
          <subChainSelector>
             <valueSelector variableName="previousStandstill"></valueSelector>
             <minimumSubChainSize>1</minimumSubChainSize>
          </subChainSelector>
          <selectReversingMoveToo>true</selectReversingMoveToo>
       </subChainSwapMoveSelector>
       <!-- TODO use nearby selection to scale out -->
    </unionMoveSelector>
    <acceptor>
       <lateAcceptanceSize>400</lateAcceptanceSize>
     </acceptor>
     <forager>
        <acceptedCountLimit>1</acceptedCountLimit>
     </forager>
</localSearch>
</solver>
Reply all
Reply to author
Forward
Message has been deleted
0 new messages