org.eclipse.viatra.dse.objectives.impl

## Class CompositeObjective

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

- All Implemented Interfaces:
    IObjective

      public class CompositeObjective
      extends BaseObjective

  This objective collects a list of other objectives. It returns the weighted sum of the objectives.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `DEFAULT_NAME`
    `protected boolean` | `hardObjective`
    `protected java.util.List<IObjective>` | `objectives`
    `protected java.util.List<java.lang.Double>` | `weights`

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

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CompositeObjective()`
    `CompositeObjective(java.util.List<IObjective> objectives, java.util.List<java.lang.Double> weights)`
    `CompositeObjective(java.lang.String name)`
    `CompositeObjective(java.lang.String name, java.util.List<IObjective> objectives, java.util.List<java.lang.Double> weights)`

  - ### 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.
    `boolean` | `isHardObjective()` Returns true if the objective is a hard objective.
    `boolean` | `satisifiesHardObjective(java.lang.Double fitness)` Determines if the given fitness value satisfies the hard objective.
    `CompositeObjective` | `withObjective(IObjective objective)` Adds a new objective.
    `CompositeObjective` | `withObjective(IObjective objective, double weight)` Adds a new objective.

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

      `equals, getComparator, getLevel, getName, hashCode, 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

    - #### objectives

          protected java.util.List<IObjective> objectives

    - #### weights

          protected java.util.List<java.lang.Double> weights

    - #### hardObjective

          protected boolean hardObjective

  - ### Constructor Detail

    - #### CompositeObjective

          public CompositeObjective(java.lang.String name,
                                    java.util.List<IObjective> objectives,
                                    java.util.List<java.lang.Double> weights)

    - #### CompositeObjective

          public CompositeObjective(java.util.List<IObjective> objectives,
                                    java.util.List<java.lang.Double> weights)

    - #### CompositeObjective

          public CompositeObjective(java.lang.String name)

    - #### CompositeObjective

          public CompositeObjective()

  - ### Method Detail

    - #### withObjective

          public CompositeObjective withObjective(IObjective objective)

      Adds a new objective.
      Parameters:
        `objective` -
      Returns:
        The actual instance to enable builder pattern like usage.

    - #### withObjective

          public CompositeObjective withObjective(IObjective objective,
                                                  double weight)

      Adds a new objective.
      Parameters:
        `objective` -
      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.

    - #### isHardObjective

          public boolean isHardObjective()

      Description copied from interface: `IObjective`
      Returns true if the objective is a hard objective. In such a case the method `IObjective.satisifiesHardObjective(Double)` is called.
      Specified by:
        `isHardObjective` in interface `IObjective`
      Overrides:
        `isHardObjective` in class `BaseObjective`
      Returns:
        True if the objective is a hard objective.
      See Also:
        `IObjective.satisifiesHardObjective(Double)`, `IObjective`

    - #### satisifiesHardObjective

          public boolean satisifiesHardObjective(java.lang.Double fitness)

      Description copied from interface: `IObjective`
      Determines if the given fitness value satisfies the hard objective.
      Specified by:
        `satisifiesHardObjective` in interface `IObjective`
      Overrides:
        `satisifiesHardObjective` in class `BaseObjective`
      Parameters:
        `fitness` - The fitness value of a solution.
      Returns:
        True if it satisfies the hard objective or it is a soft constraint.
      See Also:
        `IObjective`