Record Class LegacyMoveAdapter<Solution_>
- Type Parameters:
Solution_-- Record Components:
legacyMove- the move to adapt
- All Implemented Interfaces:
Move<Solution_>
Move a legacy move)
to a new move.
Once the move selector framework is removed, this may be removed as well.-
Constructor Summary
ConstructorsConstructorDescriptionLegacyMoveAdapter(Move<Solution_> legacyMove) Creates an instance of aLegacyMoveAdapterrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondescribe()Describes the move type for statistical purposes.final booleanIndicates whether some other object is "equal to" this one.voidexecute(MutableSolutionView<Solution_> solutionView) Runs the move and optionally records the changes done, so that they can be undone later.Collection<?>Returns all planning entities that this move is changing.Collection<?>Returns all planning values that this move is assigning to entity variables.final inthashCode()Returns a hash code value for this object.static <Solution_>
booleanisDoable(MoveDirector<Solution_, ?> moveDirector, Move<Solution_> move) Used to determine if a move is doable.booleanisMoveDoable(SolutionView<Solution_> solutionView) Returns the value of thelegacyMoverecord component.Rebases a move from an originScoreDirectorto another destinationScoreDirectorwhich is usually on anotherThread.toString()Returns a string representation of this record class.
-
Constructor Details
-
LegacyMoveAdapter
Creates an instance of aLegacyMoveAdapterrecord class.- Parameters:
legacyMove- the value for thelegacyMoverecord component
-
-
Method Details
-
isDoable
public static <Solution_> boolean isDoable(MoveDirector<Solution_, ?> moveDirector, Move<Solution_> move) Used to determine if a move is doable. A move is only doable if:- It is a new
Moveand not aNoChangeMove - It is a legacy move and its
Move.isMoveDoable(ScoreDirector)return false.
- Parameters:
moveDirector- never nullmove- never null- Returns:
- true if the move is doable
- It is a new
-
execute
Description copied from interface:MoveRuns the move and optionally records the changes done, so that they can be undone later. -
isMoveDoable
-
describe
Description copied from interface:MoveDescribes the move type for statistical purposes. For example, a move which changes a variable "computer" on a class "Process" could be described as "ChangeMove(Process.computer)".The format is not formalized. Never parse the
Stringreturned by this method. -
rebase
Description copied from interface:MoveRebases a move from an originScoreDirectorto another destinationScoreDirectorwhich is usually on anotherThread. It is necessary for multithreaded solving to function.The new move returned by this method translates the entities and problem facts to the destination
PlanningSolutionof the destinationScoreDirector, That destinationPlanningSolutionis a deep planning clone (or an even deeper clone) of the originPlanningSolutionthat this move has been generated from.That new move does the exact same change as this move, resulting in the same
PlanningSolutionstate, presuming that destinationPlanningSolutionwas in the same state as the originalPlanningSolutionto begin with.An implementation of this method typically iterates through every entity and fact instance in this move, translates each one to the destination
ScoreDirectorwithRebaser.rebase(Object)and creates a new move instance of the same move type, using those translated instances.The destination
PlanningSolutioncan be in a different state than the originalPlanningSolution. So, rebasing can only depend on the identity ofplanning entitiesandproblem facts, which are usually declared by aPlanningIdon those classes. It must not depend on the state of theplanning variables. One thread might rebase a move before, amid or after another thread does that same move instance.This method is thread-safe.
-
extractPlanningEntities
Description copied from interface:MoveReturns all planning entities that this move is changing. Required for entity tabu.This method is only called after
Move.execute(MutableSolutionView), which might affect the return values.Duplicate entries in the returned
Collectionare best avoided. The returnedCollectionis recommended to be in a stable order. For example, useListorLinkedHashSet, but notHashSet.- Specified by:
extractPlanningEntitiesin interfaceMove<Solution_>- Returns:
- Each entity only once.
-
extractPlanningValues
Description copied from interface:MoveReturns all planning values that this move is assigning to entity variables. Required for value tabu.This method is only called after
Move.execute(MutableSolutionView), which might affect the return values.Duplicate entries in the returned
Collectionare best avoided. The returnedCollectionis recommended to be in a stable order. For example, useListorLinkedHashSet, but notHashSet.- Specified by:
extractPlanningValuesin interfaceMove<Solution_>- Returns:
- Each value only once.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
legacyMove
Returns the value of thelegacyMoverecord component.- Returns:
- the value of the
legacyMoverecord component
-