Package org.eclipse.viatra.query.runtime.localsearch.planner

## Class PlanState

- java.lang.Object
- - org.eclipse.viatra.query.runtime.localsearch.planner.PlanState

-     public class PlanState
      extends java.lang.Object

  This class represents the state of the plan during planning.

  A PlanState represents a sequence of operations (operationsList) and caches the computed cost for this operation sequence. The list and the cost are initialized in the constructor. However, #categorizeChecks() also updates the operations list (by suffixing checks)

  No Reference:
    This class is not intended to be referenced by clients.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `PlanState​(PBody pBody, java.util.Set<PVariable> boundVariables)` | Creates an initial state

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `applyChecks​(java.util.List<PConstraintInfo> allPotentialCheckInfos)` | Check operations that newly became applicable (see `getDeltaVariables()`) are appended to operations lists.
    `void` | `applyChecksBasedOnDelta​(java.util.Map<PVariable,​java.util.List<PConstraintInfo>> checkOpsByVariables)` | Immediately applicable checks are appended to operations lists.
    `PlanState` | `cloneWithApplied​(PConstraintInfo op)` |
    `PBody` | `getAssociatedPBody()` |
    `java.util.Set<PVariable>` | `getBoundVariables()` |
    `double` | `getCost()` |
    `double` | `getCummulativeProduct()` |
    `java.util.Collection<PVariable>` | `getDeltaVariables()` | Contains only those variables that are added by the newest extend (or the initially bound ones if no extend yet)
    `java.util.Set<PConstraint>` | `getEnforcedConstraints()` |
    `java.util.List<PConstraintInfo>` | `getOperations()` |
    `java.util.List<PConstraintInfo>` | `getPresentExtends()` |
    `void` | `updateExtends​(java.lang.Iterable<PConstraintInfo> allPotentialExtendInfos)` | Re-categorizes given extend operations into already applied or no longer applicable ones (discarded), immediately applicable ones (saved as presently viable extends), and not yet applicable ones (discarded).
    `void` | `updateExtendsBasedOnDelta​(java.lang.Iterable<PConstraintInfo> previousPresentExtends, java.util.Map<PVariable,​? extends java.util.Collection<PConstraintInfo>> extendOpsByBoundVariables)` | Re-categorizes given extend operations into already applied or no longer applicable ones (discarded), immediately applicable ones (saved as presently viable extends), and not yet applicable ones (discarded).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PlanState

          public PlanState​(PBody pBody,
                           java.util.Set<PVariable> boundVariables)

      Creates an initial state

  - ### Method Detail

    - #### cloneWithApplied

          public PlanState cloneWithApplied​(PConstraintInfo op)

    - #### getEnforcedConstraints

          public java.util.Set<PConstraint> getEnforcedConstraints()

    - #### updateExtends

          public void updateExtends​(java.lang.Iterable<PConstraintInfo> allPotentialExtendInfos)

      Re-categorizes given extend operations into already applied or no longer applicable ones (discarded), immediately applicable ones (saved as presently viable extends), and not yet applicable ones (discarded).
      Parameters:
        `allPotentialExtendInfos` - all other extends that may be applicable to this plan state now or in the future; MUST consist of "extend" constraint applications only (at least one free variable)

    - #### updateExtendsBasedOnDelta

          public void updateExtendsBasedOnDelta​(java.lang.Iterable<PConstraintInfo> previousPresentExtends,
                                                java.util.Map<PVariable,​? extends java.util.Collection<PConstraintInfo>> extendOpsByBoundVariables)

      Re-categorizes given extend operations into already applied or no longer applicable ones (discarded), immediately applicable ones (saved as presently viable extends), and not yet applicable ones (discarded).
      Parameters:
        `extendOpsByBoundVariables` - all EXTEND operations indexed by affected bound variables MUST consist of "extend" constraint applications only (at least one free variable)

    - #### applyChecks

          public void applyChecks​(java.util.List<PConstraintInfo> allPotentialCheckInfos)

      Check operations that newly became applicable (see `getDeltaVariables()`) are appended to operations lists.

      Will never discover degenerate checks (of PConstraints with zero variables), so must not use on initial state.

      Parameters:
        `allPotentialCheckInfos` - all CHECK operations MUST consist of "check" constraint applications only (no free variables) and must be iterable in decreasing order of cost

    - #### applyChecksBasedOnDelta

          public void applyChecksBasedOnDelta​(java.util.Map<PVariable,​java.util.List<PConstraintInfo>> checkOpsByVariables)

      Immediately applicable checks are appended to operations lists.
      Parameters:
        `checkOpsByVariables` - all CHECK operations indexed by affected variables MUST consist of "check" constraint applications only (no free variables) and each bucket must be iterable in decreasing order of cost

    - #### getAssociatedPBody

          public PBody getAssociatedPBody()

    - #### getOperations

          public java.util.List<PConstraintInfo> getOperations()

    - #### getBoundVariables

          public java.util.Set<PVariable> getBoundVariables()

    - #### getCost

          public double getCost()

      Returns:
        the derived cost of the plan contained in the state

    - #### getCummulativeProduct

          public double getCummulativeProduct()

      Returns:
        cumulative branching factor
      Since:
        2.1

    - #### getPresentExtends

          public java.util.List<PConstraintInfo> getPresentExtends()

    - #### getDeltaVariables

          public java.util.Collection<PVariable> getDeltaVariables()

      Contains only those variables that are added by the newest extend (or the initially bound ones if no extend yet)