user2952819
user2952819

Reputation: 111

How to use OptaPlanner ValueRange from planning entity?

I'm attempting to limit the planning variables that can be associated with a particular entity. In the OptaPlanner manual in section 4.3.4.2.2, an example is shown, but it isn't clear how the list of variables should be generated. What should the list contain? Are these planning variables themselves? Can they be copies? If copies are allowed, then how are they compared? If not, the planning variable is not in scope when defining the planning entity - I realize that this is a Java question, but it isn't apparent how to access the list of planning variables from the planning entity definition.

Is this is a 6.1 feature that was not supported in earlier versions?

Will the Working Memory size be constrained by using this feature? That is my goal.

Your assistance is greatly appreciated!

Here's the example from the manual:

@PlanningVariable

@ValueRange(type = ValueRangeType.FROM_PLANNING_ENTITY_PROPERTY, planningEntityProperty = "possibleRoomList")

public Room getRoom() {

    return room;

}


public List<Room> getPossibleRoomList() {

    return getCourse().getTeacher().getPossibleRoomList();

}

Upvotes: 1

Views: 632

Answers (1)

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27312

Let's set the terminology straight first: The planning variable (for example getRoom() in the example) has a value range (which is a list of planning values) which different from entity instance to entity instance.

About such a List of planning values:

  • Each entity has it's own List instance, although multiple entities can share the same List instance if they have the exact same value range.
  • No copies: A planning value instance should only exists once in a Solution. So 2 entities with different value ranges, but with the same planning value in their value ranges, should be using the same planning value instance.

Upvotes: 1

Related Questions