Bibou3618
Bibou3618

Reputation: 41

optaplanner immovable planning entities

I'm working with Optaplanner to solve a problem similar to the patient admission scheduling example.

I'm facing two problems.

Firstly when one of the planning entities (similar to bedDesignation of the example) is positioned by someone (not optaplanner), this planning entity is scored like the others. The planning entity manually placed become an immovable planning entity but it is still scored like movable planning entity. And because of that it breaks some hard constraint.

Secondly still when one of the planning entities (similar to bedDesignation) is positioned by someone (not optaplanner), this planning entity is moved during the local search phase. The local search phase is configured like this (same configuration than the example) :

  <localSearch>
    <unionMoveSelector>
      <moveListFactory>
        <moveListFactoryClass>org.optaplanner.examples.pas.solver.move.factory.BedDesignationPillarPartSwapMoveFactory</moveListFactoryClass>
      </moveListFactory>
    </unionMoveSelector>
    <acceptor>
      <entityTabuSize>7</entityTabuSize>
    </acceptor>
    <forager>
      <acceptedCountLimit>1000</acceptedCountLimit>
    </forager>
  </localSearch>

The BedDesignationPillarPartSwapMoveFactory class is unchanged from the example. I read in the documentation that for an immovable planning entities we must make sure that the custom moveListFactory don't move immovable entities. But how ? In the config xml file or in the class itself ?

Thank you for your help.

Upvotes: 1

Views: 753

Answers (1)

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27337

Adjust the BedDesignationPillarPartSwapMoveFactory to skip entities (BedDesignations) that aren't movable (for example if they are isLocked() == true).

Or better yet: don't use BedDesignationPillarPartSwapMoveFactory at all, just go with generic move selectors: changeMove, swapMove, pillarChangeMove and pillarSwapMove. The pillar moves now select subpillars in 6.2, but I haven't tested yet if this gives better results on that example (I believe it will) - which could make the custom move factory obsolete.

Upvotes: 1

Related Questions