org.eclipse.viatra.dse.objectives.impl

## Class TrajectoryCostSoftObjective

- java.lang.Object
- - org.eclipse.viatra.dse.objectives.impl.BaseObjective
  - - org.eclipse.viatra.dse.objectives.impl.TrajectoryCostSoftObjective

- All Implemented Interfaces:
    IObjective

      public class TrajectoryCostSoftObjective
      extends BaseObjective

  This soft objective calculates a fitness value based on the length of the trajectory. Costs to the rules can be assigned.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Map<BatchTransformationRule<?,?>,ActivationFitnessProcessor>` | `activationCostProcessors`
    `protected boolean` | `calculateTrajectoryLengthWeight`
    `static java.lang.String` | `DEFAULT_NAME`
    `protected java.util.Map<BatchTransformationRule<?,?>,java.lang.Double>` | `fixCosts`
    `protected double` | `trajectoryLengthWeight`

    - ### Fields inherited from class org.eclipse.viatra.dse.objectives.impl.BaseObjective

      `comparator, fitnessConstraint, fitnessConstraintComparator, isThereFitnessConstraint, level, name`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TrajectoryCostSoftObjective()`
    `TrajectoryCostSoftObjective(java.lang.String name)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `IObjective` | `createNew()` Returns an instance of the `IObjective`.
    `java.lang.Double` | `getFitness(ThreadContext context)` Calculates the value of the objective on a given solution (trajectory).
    `void` | `init(ThreadContext context)` Initializes the objective.
    `TrajectoryCostSoftObjective` | `withActivationCost(BatchTransformationRule<?,?> rule, ActivationFitnessProcessor activationCostProcessor)` Sets an activation processor for a rule.
    `TrajectoryCostSoftObjective` | `withRuleCost(BatchTransformationRule<?,?> rule, double cost)` Sets the cost of a rule.
    `TrajectoryCostSoftObjective` | `withTrajectoryLengthWeight(double trajectoryLengthWeight)` The length of the trajectory multiplied with given parameter will be added to the fitness value.

    - ### Methods inherited from class org.eclipse.viatra.dse.objectives.impl.BaseObjective

      `equals, getComparator, getLevel, getName, hashCode, isHardObjective, satisifiesHardObjective, setComparator, setLevel, toString, withComparator, withHardConstraintOnFitness, withHardConstraintOnFitness, withLevel`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_NAME

          public static final java.lang.String DEFAULT_NAME

      See Also:
        Constant Field Values

    - #### fixCosts

          protected java.util.Map<BatchTransformationRule<?,?>,java.lang.Double> fixCosts

    - #### activationCostProcessors

          protected java.util.Map<BatchTransformationRule<?,?>,ActivationFitnessProcessor> activationCostProcessors

    - #### trajectoryLengthWeight

          protected double trajectoryLengthWeight

    - #### calculateTrajectoryLengthWeight

          protected boolean calculateTrajectoryLengthWeight

  - ### Constructor Detail

    - #### TrajectoryCostSoftObjective

          public TrajectoryCostSoftObjective(java.lang.String name)

    - #### TrajectoryCostSoftObjective

          public TrajectoryCostSoftObjective()

  - ### Method Detail

    - #### withRuleCost

          public TrajectoryCostSoftObjective withRuleCost(BatchTransformationRule<?,?> rule,
                                                          double cost)

      Sets the cost of a rule.
      Parameters:
        `rule` -
        `cost` -
      Returns:
        The actual instance to enable builder pattern like usage.

    - #### withActivationCost

          public TrajectoryCostSoftObjective withActivationCost(BatchTransformationRule<?,?> rule,
                                                                ActivationFitnessProcessor activationCostProcessor)

      Sets an activation processor for a rule.
      Parameters:
        `rule` -
        `activationCostProcessor` -
      Returns:
        The actual instance to enable builder pattern like usage.

    - #### withTrajectoryLengthWeight

          public TrajectoryCostSoftObjective withTrajectoryLengthWeight(double trajectoryLengthWeight)

      The length of the trajectory multiplied with given parameter will be added to the fitness value.
      Parameters:
        `trajectoryLengthWeight` - The weight of a transformation rule application.
      Returns:
        The actual instance to enable builder pattern like usage.

    - #### getFitness

          public java.lang.Double getFitness(ThreadContext context)

      Description copied from interface: `IObjective`
      Calculates the value of the objective on a given solution (trajectory).
      Parameters:
        `context` - The `ThreadContext`
      Returns:
        The objective value in double.

    - #### init

          public void init(ThreadContext context)

      Description copied from interface: `IObjective`
      Initializes the objective. It is called exactly once for every thread starts.
      Specified by:
        `init` in interface `IObjective`
      Overrides:
        `init` in class `BaseObjective`
      Parameters:
        `context` - The `ThreadContext`.

    - #### createNew

          public IObjective createNew()

      Description copied from interface: `IObjective`
      Returns an instance of the `IObjective`. If it returns the same instance, all the methods has to be thread save as they are called concurrently.
      Returns:
        An instance of the objective.