lv.lumii.layoutengine.funcmin

## Class ExtendedQuadraticOptimizer

- java.lang.Object
- - lv.lumii.layoutengine.funcmin.QuadraticOptimizer
  - - lv.lumii.layoutengine.funcmin.ExtendedQuadraticOptimizer

-     public class ExtendedQuadraticOptimizer
      extends QuadraticOptimizer

  Extends the `QuadraticOptimizer` class to allow for some variables to have a fixed value and for some inequalities to be unsatisfiable, as long as satisfiable fallback is provided. Implemented as a separate class as it is slightly slower due to the additional terms used.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExtendedQuadraticOptimizer(int variableCount)` The constructor creates a zero function with no constraints.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addConstantEquality(int i, double value)` Adds the following equality constraint: `xi=value`.
    `void` | `addConstantInequality(int i, double value)` Add an inequality constraint in the form of `xi≥value`.
    `void` | `addConstantReverseInequality(int i, double value)` Add an inequality constraint in the form of `xi≤value`.
    `void` | `addMeanDifference(int i, int j, double value, double weight)` Add a new term in the form of `weight*((xi+xj)/2-value)2`.
    `void` | `addQuadraticConstantDifference(int i, double value, double weight)` Add a new term in the form of `weight*(xi-value)2`.
    `void` | `addReducibleInequality(int i, int j, double distance, double minDistance)` Adds an inequality constraint in the form of `xj-xi≥distance≥minDistance`.
    `double[]` | `performOptimization()` Performs the function minimization using the given terms and constraints.

    - ### Methods inherited from class lv.lumii.layoutengine.funcmin.QuadraticOptimizer

      `addCombinedTerm, addDoubleMeanConstantDifference, addDoubleMeanDifference, addEquality, addInequality, addLinearDifference, addLinearTerm, addMeanVariableDifference, addQuadraticDifference, addQuadraticTerm, setEpsilon, setVariable`

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

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

- - ### Constructor Detail

    - #### ExtendedQuadraticOptimizer

          public ExtendedQuadraticOptimizer(int variableCount)

      The constructor creates a zero function with no constraints. Creates the fictional variable used to affix other variables.
      Parameters:
        `variableCount` - the number of variables

  - ### Method Detail

    - #### addQuadraticConstantDifference

          public void addQuadraticConstantDifference(int i,
                                                     double value,
                                                     double weight)

      Description copied from class: `QuadraticOptimizer`
      Add a new term in the form of `weight*(xi-value)2`. Use this method to minimize the drift of an object.
      Overrides:
        `addQuadraticConstantDifference` in class `QuadraticOptimizer`
      Parameters:
        `i` - the variable of the term
        `value` - the value to keep the variable close to
        `weight` - the weight of this term

    - #### addMeanDifference

          public void addMeanDifference(int i,
                                        int j,
                                        double value,
                                        double weight)

      Add a new term in the form of `weight*((xi+xj)/2-value)2`. Use this method to minimize the drift of the mass center of two objects.
      Overrides:
        `addMeanDifference` in class `QuadraticOptimizer`
      Parameters:
        `i` - the first variable of the term
        `j` - the second variable of the term
        `value` - the value to keep the mass center of the two objects close to
        `weight` - the weight of this term

    - #### addConstantInequality

          public void addConstantInequality(int i,
                                            double value)

      Add an inequality constraint in the form of `xi≥value`.
      Parameters:
        `i` - the variable of the inequality
        `value` - the constant of the inequality

    - #### addConstantReverseInequality

          public void addConstantReverseInequality(int i,
                                                   double value)

      Add an inequality constraint in the form of `xi≤value`.
      Parameters:
        `i` - the variable of the inequality
        `value` - the constant of the inequality

    - #### addConstantEquality

          public void addConstantEquality(int i,
                                          double value)

      Adds the following equality constraint: `xi=value`.
      Parameters:
        `i` - the variable of the equality
        `value` - the constant of the equality

    - #### addReducibleInequality

          public void addReducibleInequality(int i,
                                             int j,
                                             double distance,
                                             double minDistance)

      Adds an inequality constraint in the form of `xj-xi≥distance≥minDistance`. If the set of constraints is unsatisfiable with `distance`, they are relaxed towards `minDistance` until they are satisfiable.
      Parameters:
        `i` - the second variable of the inequality
        `j` - the first variable of the inequality
        `distance` - the minimum distance between the two variables
        `minDistance` - the minimum distance between the two variables if `distance` is not possible.

    - #### performOptimization

          public double[] performOptimization()

      Description copied from class: `QuadraticOptimizer`
      Performs the function minimization using the given terms and constraints.
      Overrides:
        `performOptimization` in class `QuadraticOptimizer`
      Returns:
        an array of the new values of the function variables.