sicario_23
sicario_23

Reputation: 11

OptaPlanner - How to configure a selectionFilter in construction heuristics phase?

I am trying to add a selectionFilter during the CH phase as below in solverConfig.xml:

    <constructionHeuristic>
        <constructionHeuristicType>FIRST_FIT</constructionHeuristicType>
        <changeMoveSelector>
            <entitySelector>
                <filterClass>org.example.entity.ShiftFilter
                </filterClass>
            </entitySelector>
        </changeMoveSelector>
    </constructionHeuristic>

After adding this to the config, the solver is not starting. The same filter works fine within a local search phase.

The error in the solve api response is as follows:

The <constructionHeuristic> contains a changeMoveSelector (ChangeMoveSelectorConfig(EntitySelectorConfig(null), null)) that contains an entitySelector (EntitySelectorConfig(null)) without explicitly configuring the <queuedEntityPlacer>

Could someone help me point in the right direction on how to add selection filer in CH.

Upvotes: 1

Views: 110

Answers (1)

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27312

Here be dragons.

From this docs section, here's an example of a proper CH power-tweaked config:

  <constructionHeuristic>
    <queuedEntityPlacer>
      <entitySelector id="placerEntitySelector">
        <!-- your filter? -->
  
      </entitySelector>
      <changeMoveSelector>
        <entitySelector mimicSelectorRef="placerEntitySelector"/>
        <valueSelector>
          
        </valueSelector>
      </changeMoveSelector>
    </queuedEntityPlacer>
  </constructionHeuristic>

That being said, in my experience, this is probably the wrong rabbit hole to follow to solve the scaling problem you want to fix.

Upvotes: 1

Related Questions