Package apron

Class Lincons1

java.lang.Object
apron.Lincons1
All Implemented Interfaces:
Serializable, Cloneable

public class Lincons1 extends Object implements Cloneable, Serializable
Class of level 1 linear constraints.

A Lincons1 represents a linear constraint over variables denoted by names in an environment.

A Lincons1 is implemented as a pair containing a (sparse or dense) Lincons0 and an Environment, manipulated in conjunction. Direct access to the fields is prohibited, to avoid desynchronizing them.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Lincons0
    Level 0 constraint.
    static final int
    Disquality constraint: expr <> 0.
    protected Environment
    Environment.
    static final int
    Equality constraint: expr = 0.
    static final int
    Congruence equality constraint modulo a constant: expr = 0 mod scalar.
    static final int
    Strict inequality constraint: expr > 0.
    static final int
    Inequality constraint: expr >= 0.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Lincons1(int k, Linexpr1 e)
    Constructs a constraint with given kind and e as left member.
    Lincons1(int k, Linexpr1 e, Scalar s)
    Constructs a constraint with given kind, e as left member, and s as modulo factor.
    Constructs a universal constraint 0 >= 0.
    Lincons1(Environment v, boolean sat)
    Constructs a constraint that is either universal (0 >= 0), or unsatisfiable (-1 >= 0).
    Creates a new Lincons1 from a Lincons0.
    Constructs a copy of c.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a copy of this.
    boolean
    Whether x is a Lincons1 and structurally equal to this.
    void
    Expands the constraint to fit the given environment.
    Returns a constraint expanded to fit the given environment.
    Returns a copy of the coefficient of variable var.
    Returns a copy of all variable coefficients.
    Returns the constant coefficient in the left member expression.
    Returns the environment of the constraint.
    int
    Returns the constraint kind.
    Returns a copy of the Lincons0 underlying the constraint.
    Returns a (read-only) reference to the Lincons0 underlying this constraint.
    Returns a copy of all variable coefficients.
    Returns the optional modulo factor (may be null).
    int
    Returns a hash of the constraint.
    boolean
    Whether this and x have identical kinds and coefficients.
    boolean
    Whether the constraint only depends on integer-valued variables.
    boolean
    Whether the constraint has only scalar coefficients.
    boolean
    Whether the constraint has only scalar coefficients, except maybe for the constant coefficient.
    boolean
    Whether the constraint only depends on real-valued variables.
    boolean
    Whether the constraint is sparse or dense.
    boolean
    Whether the constraint is trivially unsatisfiable.
    static Lincons1
    This function is used internally to construct a level 1 constraint by referencing a level 0 constraint.
    void
    Simplifies the representation.
    void
    Sets several variable coefficients at the same time.
    void
    setCoeff(Var var, Coeff c)
    Sets the coefficient of variable var to c.
    void
     
    void
    Sets the constant coefficient to c.
    void
    setKind(int k)
    Changes the kind of constraint.
    void
    Sets the optional modulo factor (may be null).
    Returns a string representation of the constraint.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • cons

      protected Lincons0 cons
      Level 0 constraint.
    • env

      protected Environment env
      Environment.
    • EQ

      public static final int EQ
      Equality constraint: expr = 0.
      See Also:
    • SUPEQ

      public static final int SUPEQ
      Inequality constraint: expr >= 0.
      See Also:
    • SUP

      public static final int SUP
      Strict inequality constraint: expr > 0.
      See Also:
    • EQMOD

      public static final int EQMOD
      Congruence equality constraint modulo a constant: expr = 0 mod scalar.
      See Also:
    • DISEQ

      public static final int DISEQ
      Disquality constraint: expr <> 0.
      See Also:
  • Constructor Details

    • Lincons1

      public Lincons1(Environment v)
      Constructs a universal constraint 0 >= 0.
    • Lincons1

      public Lincons1(Environment v, boolean sat)
      Constructs a constraint that is either universal (0 >= 0), or unsatisfiable (-1 >= 0).
    • Lincons1

      public Lincons1(int k, Linexpr1 e)
      Constructs a constraint with given kind and e as left member.

      e is copied.

    • Lincons1

      public Lincons1(int k, Linexpr1 e, Scalar s)
      Constructs a constraint with given kind, e as left member, and s as modulo factor.

      e is copied, s is referenced.

    • Lincons1

      public Lincons1(Lincons1 c)
      Constructs a copy of c.

      The left member expression and the optional scalar are copied.

    • Lincons1

      public Lincons1(Environment e, Lincons0 x)
      Creates a new Lincons1 from a Lincons0.

      All coefficients are copied.

      The environment must be large enough for all variables in x.

  • Method Details

    • make

      public static Lincons1 make(Environment v, Lincons0 x)
      This function is used internally to construct a level 1 constraint by referencing a level 0 constraint.

      The level 0 constraint should no longer be used afterwards.

    • setCst

      public void setCst(Coeff c)
      Sets the constant coefficient to c.

      The coefficient is copied.

    • setCoeff

      public void setCoeff(String var, Coeff c)
    • setCoeff

      public void setCoeff(Var var, Coeff c)
      Sets the coefficient of variable var to c.
    • setCoeff

      public void setCoeff(Linterm1[] c)
      Sets several variable coefficients at the same time.

      All coefficients are copied.

    • setKind

      public void setKind(int k)
      Changes the kind of constraint.
    • setScalar

      public void setScalar(Scalar s)
      Sets the optional modulo factor (may be null).
    • getEnvironment

      public Environment getEnvironment()
      Returns the environment of the constraint.
    • getKind

      public int getKind()
      Returns the constraint kind.
    • getScalar

      public Scalar getScalar()
      Returns the optional modulo factor (may be null).
    • getLincons0

      public Lincons0 getLincons0()
      Returns a copy of the Lincons0 underlying the constraint.
    • getLincons0Ref

      public Lincons0 getLincons0Ref()

      Returns a (read-only) reference to the Lincons0 underlying this constraint.

      Warning: it is dangerous to add coefficients, resize the constraint, add, remove, or permute dimensions as it may desynchrnonize the Lincons0 dimensions and the environment.

    • getCst

      public Coeff getCst()
      Returns the constant coefficient in the left member expression.
    • getCoeff

      public Coeff getCoeff(Var var)
      Returns a copy of the coefficient of variable var.
    • getLinterms

      public Linterm1[] getLinterms()
      Returns a copy of all variable coefficients.
      See Also:
    • getCoeffs

      public Coeff[] getCoeffs()
      Returns a copy of all variable coefficients.
      See Also:
    • toString

      public String toString()
      Returns a string representation of the constraint.
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Returns a hash of the constraint.
      Overrides:
      hashCode in class Object
    • isSparse

      public boolean isSparse()
      Whether the constraint is sparse or dense.
    • isInteger

      public boolean isInteger()
      Whether the constraint only depends on integer-valued variables.
    • isReal

      public boolean isReal()
      Whether the constraint only depends on real-valued variables.
    • isLinear

      public boolean isLinear()
      Whether the constraint has only scalar coefficients.
    • isQuasilinear

      public boolean isQuasilinear()
      Whether the constraint has only scalar coefficients, except maybe for the constant coefficient.
    • isUnsat

      public boolean isUnsat()
      Whether the constraint is trivially unsatisfiable.

      Returns true if the constraint has the form b >= 0 or [a,b] >= 0 with b negative.

    • isEqual

      public boolean isEqual(Lincons1 x)
      Whether this and x have identical kinds and coefficients.
    • minimize

      public void minimize()
      Simplifies the representation.
      See Also:
    • extendEnvironment

      public void extendEnvironment(Environment e)
      Expands the constraint to fit the given environment.

      e must be a super-environment of that of this.

    • extendEnvironmentCopy

      public Lincons1 extendEnvironmentCopy(Environment e)
      Returns a constraint expanded to fit the given environment.

      e must be a super-environment of that of this.

      this is not modified.

    • clone

      public Lincons1 clone()
      Returns a copy of this.
      Overrides:
      clone in class Object
    • equals

      public boolean equals(Object x)
      Whether x is a Lincons1 and structurally equal to this.
      Overrides:
      equals in class Object