3

I want to use "pin" feature of optaplanner for immovable operations. However i get "Bailing out of neverEnding selector (Filtering(FromSolutionEntitySelector(PersonAssignment))) to avoid infinite loop." error. I've tried both with @PlanningPin and movableEntitySelectionFilter. Optaplanner version is 7.32.0 final, also i tried with version 7.44.0.Final. I've searched a lot and as can i see you've solved this problem in version 7.31.0.Final.

I've generated my domain and it is working well. Idea of my problem is there are more then one hotel. People come to hotel at different hours. Each hotel has different capacity and i want to asign people to a hotel if there is enough space. I've also many rules about assignment. My domain model consists of two @PlanningEntity,customShadowVariable and also TimeGrain. Structure is below:

@PlanningEntity(movableEntitySelectionFilter = PersonAssignmentSelectionFilter.class)
public class PersonAssignment extends AbstractPersistable {

private Person person;

private TimeGrain startingTimeGrain;

private TimeGrain endTime; // This added

private HotelDomain hotelDomain;


public TimeGrain getStartingTimeGrain() {
      return startingTimeGrain;
}

public void setStartingTimeGrain(TimeGrain startingTimeGrain) {
      this.startingTimeGrain = startingTimeGrain;
}

public TimeGrain getEndTime() {
      return endTime;
}

public void setEndTime(TimeGrain endTime) {
      this.endTime = endTime;
}

@PlanningVariable(valueRangeProviderRefs = { "hotelDomainRange" }, nullable = true)
    public HotelDomain getHotelDomain() {
      return hotelDomain;
}

public void setHotelDomain(HotelDomain hotelDomain) {
      this.hotelDomain = hotelDomain;
}
......
}

@DeepPlanningClone 
public class HotelDomain extends AbstractPersistable {

private String hotelName;

@CustomShadowVariable(variableListenerRef = @PlanningVariableReference(variableName = "tightOccupancy, personAssignment))
   private Map<Integer, HotelOccupancyPerSlot> hotelOccupancyMap;

......
}

@PlanningEntity
public class HotelOccupancyPerSlot extends AbstractPersistable {

 @CustomShadowVariable(variableListenerClass = HotelDomainVariableListener.class, sources = {
         @PlanningVariableReference(entityClass = PersonAssignment.class, variableName = "hotelDomain") })
   private Integer tightOccupancy; // days

   @CustomShadowVariable(variableListenerRef = @PlanningVariableReference(variableName = "tightOccupancy"))
   private List<PersonAssignment> personAssignments;

.......
}

public class HotelDomainVariableListener implements VariableListener<PersonAssignment> {
......
}

config.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<solver>
    <moveThreadCount>3</moveThreadCount> <!-- To solve faster by saturating multiple CPU cores -->
    <solutionClass>com.domain.HotelAccomodation</solutionClass>
    <entityClass>com.domain.PersonAssignment</entityClass>
    <entityClass>com.domain.HotelOccupancyPerSlot</entityClass>

    <scoreDirectorFactory>
        <scoreDrl>solver/solverScoreRules.drl</scoreDrl>
    </scoreDirectorFactory>
  
    <termination>
         <minutesSpentLimit>15</minutesSpentLimit>
    </termination>
</solver>

If i use @PlannigPin in HotelOccupancyPerSlot there is no problem but i want to use it(or filter) only in PersonAssignment class because it is my basic class. Is there any suggestion? Should i add something to config?

Thank You :)

ahmetesat
  • 73
  • 6

1 Answers1

1

The "Bailing out" warning happens when a move selection filter is filtering out every move (it never returns true). It's not an error, but a warning, because there if you see it only once, it could be a harmless fluke in theory in some cases.

Anyway, when does a filter return false for all selected moves? In these cases:

  • A) you configured a custom move filter in solverConfig.xml that never returns true
  • B) the solution value range has no values - OptaPlanner checks for that ins 7.44+ and does the right thing automatically. Not sure if it does the right thing if there are 2 planning variables and only 1 has no values...
  • C) the solution value range has a single value - that would mean the move isDoable() false. I don't recall this being a problem though.
  • D) the solution value range has no non-pinned value. See B)
  • E) the solution value range has only 1 non-pinned value. See C)

Take a look at your input data. Are you dealing with case B, C, D or E by any chance?

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • 1
    Case D. Gives this warning when all of the PersonAssignment entity pinned. It just log this warning and then nothing happens. – ahmetesat Oct 14 '20 at 11:29
  • 1
    Ah, I see. And because not all the hotel assignments are pinned, you can't just say "well, there is no point in solving then". This is an issue, please create a jira. https://issues.redhat.com/projects/PLANNER/issues – Geoffrey De Smet Oct 15 '20 at 06:58