Pejal Hebat
Pejal Hebat

Reputation: 116

Optaplanner produces only single chain solution

I am using Optaplanner to solve an installer booking assignment problem, which is a chaining problem, similar to vehicle routing. An installer(vehicle) may have multiple bookings(customer) assigned to it. I need to implement the chain because I need to evaluate one booking in relation to another booking an a particular order. So, I declared Booking and Installer as @PlanningEntityCollectionProperty in my Solution. Both Booking and Installer implements Standstill. But only in Booking I declared @PlanningVariable for method getPreviousStandstill().

My config:

<solver>
  <!--<environmentMode>FAST_ASSERT</environmentMode>-->

  <!-- Domain model configuration -->
  <solutionClass>InstallationSolution</solutionClass>
  <entityClass>Standstill</entityClass>
  <entityClass>Booking</entityClass>



  <!-- Score configuration -->
  <scoreDirectorFactory>
    <scoreDefinitionType>HARD_SOFT</scoreDefinitionType>
    <!--<easyScoreCalculatorClass>org.optaplanner.examples.cloudbalancing.solver.score.CloudBalancingEasyScoreCalculator</easyScoreCalculatorClass>-->
    <!--<easyScoreCalculatorClass>org.optaplanner.examples.cloudbalancing.solver.score.CloudBalancingMapBasedEasyScoreCalculator</easyScoreCalculatorClass>-->
    <!--<incrementalScoreCalculatorClass>org.optaplanner.examples.cloudbalancing.solver.score.CloudBalancingIncrementalScoreCalculator</incrementalScoreCalculatorClass>-->
    <!--<scoreDrl>com/tmrnd/pejal/opta/solver/fulfillmentScoreRules.drl</scoreDrl>-->
    <initializingScoreTrend>ONLY_DOWN</initializingScoreTrend>
    <!--<assertionScoreDirectorFactory>-->
      <!--<easyScoreCalculatorClass>org.optaplanner.examples.cloudbalancing.solver.score.CloudBalancingMapBasedEasyScoreCalculator</easyScoreCalculatorClass>-->
    <!--</assertionScoreDirectorFactory>-->
  </scoreDirectorFactory>

  <!-- Optimization algorithms configuration -->
  <termination>
    <!-- <secondsSpentLimit>20</secondsSpentLimit>-->
    <unimprovedSecondsSpentLimit>15</unimprovedSecondsSpentLimit>
  </termination>
  <constructionHeuristic>
    <constructionHeuristicType>FIRST_FIT_DECREASING</constructionHeuristicType>

  </constructionHeuristic>
  <localSearch>
    <unionMoveSelector>
      <changeMoveSelector/>
      <swapMoveSelector/>
      <subChainChangeMoveSelector>
        <selectReversingMoveToo>true</selectReversingMoveToo>
      </subChainChangeMoveSelector>
      <subChainSwapMoveSelector>
        <selectReversingMoveToo>true</selectReversingMoveToo>
      </subChainSwapMoveSelector>
    </unionMoveSelector>
    <acceptor>
      <entityTabuSize>20</entityTabuSize>

    </acceptor>
    <forager>
      <acceptedCountLimit>1000</acceptedCountLimit>
    </forager>
  </localSearch>
</solver>

When I try to solve(), I got one installer with all bookings asssigned to him. What do I need to do to improve the situation?

Upvotes: 0

Views: 453

Answers (1)

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27312

My initial guess would be you have only 1 anchor (1 installer) known to OptaPlanner. Check if the Solution's List's size is bigger than 1 in size. Then check if getter has @ValueRangeProvider and if the id of that ValueRangeProvider is added in the @PlanningEntity's valueRangeProviderRefs.

Also be aware of a common pitfall that might apply here too (but shouldn't if you use value range providers properly): list.add(list) instead of list.addAll(list).

Upvotes: 1

Related Questions