public class Lincons1
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
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.
Modifier and Type | Field and Description |
---|---|
protected Lincons0 |
cons
Level 0 constraint.
|
static int |
DISEQ
Disquality constraint: expr <> 0.
|
protected Environment |
env
Environment.
|
static int |
EQ
Equality constraint: expr = 0.
|
static int |
EQMOD
Congruence equality constraint modulo a constant:
expr = 0 mod scalar.
|
static int |
SUP
Strict inequality constraint: expr > 0.
|
static int |
SUPEQ
Inequality constraint: expr >= 0.
|
Constructor and Description |
---|
Lincons1(Environment v)
Constructs a universal constraint 0 >= 0.
|
Lincons1(Environment v,
boolean sat)
Constructs a constraint that is either universal (0 >= 0), or
unsatisfiable (-1 >= 0).
|
Lincons1(Environment e,
Lincons0 x)
Creates a new Lincons1 from a Lincons0.
|
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.
|
Lincons1(Lincons1 c)
Constructs a copy of c.
|
Modifier and Type | Method and Description |
---|---|
Lincons1 |
clone()
Returns a copy of this.
|
boolean |
equals(java.lang.Object x)
Whether x is a Lincons1 and structurally equal to this.
|
void |
extendEnvironment(Environment e)
Expands the constraint to fit the given environment.
|
Lincons1 |
extendEnvironmentCopy(Environment e)
Returns a constraint expanded to fit the given environment.
|
Coeff |
getCoeff(Var var)
Returns a copy of the coefficient of variable var.
|
Coeff[] |
getCoeffs()
Returns a copy of all variable coefficients.
|
Coeff |
getCst()
Returns the constant coefficient in the left member expression.
|
Environment |
getEnvironment()
Returns the environment of the constraint.
|
int |
getKind()
Returns the constraint kind.
|
Lincons0 |
getLincons0()
Returns a copy of the Lincons0 underlying the constraint.
|
Lincons0 |
getLincons0Ref()
Returns a (read-only) reference to the Lincons0 underlying
this constraint.
|
Linterm1[] |
getLinterms()
Returns a copy of all variable coefficients.
|
Scalar |
getScalar()
Returns the optional modulo factor (may be null).
|
int |
hashCode()
Returns a hash of the constraint.
|
boolean |
isEqual(Lincons1 x)
Whether this and x have identical kinds and coefficients.
|
boolean |
isInteger()
Whether the constraint only depends on integer-valued variables.
|
boolean |
isLinear()
Whether the constraint has only scalar coefficients.
|
boolean |
isQuasilinear()
Whether the constraint has only scalar coefficients, except maybe
for the constant coefficient.
|
boolean |
isReal()
Whether the constraint only depends on real-valued variables.
|
boolean |
isSparse()
Whether the constraint is sparse or dense.
|
boolean |
isUnsat()
Whether the constraint is trivially unsatisfiable.
|
static Lincons1 |
make(Environment v,
Lincons0 x)
This function is used internally to construct a level 1 constraint
by referencing a level 0 constraint.
|
void |
minimize()
Simplifies the representation.
|
void |
setCoeff(Linterm1[] c)
Sets several variable coefficients at the same time.
|
void |
setCoeff(java.lang.String var,
Coeff c) |
void |
setCoeff(Var var,
Coeff c)
Sets the coefficient of variable var to c.
|
void |
setCst(Coeff c)
Sets the constant coefficient to c.
|
void |
setKind(int k)
Changes the kind of constraint.
|
void |
setScalar(Scalar s)
Sets the optional modulo factor (may be null).
|
java.lang.String |
toString()
Returns a string representation of the constraint.
|
protected Lincons0 cons
protected Environment env
public static final int EQ
public static final int SUPEQ
public static final int SUP
public static final int EQMOD
public static final int DISEQ
public Lincons1(Environment v)
public Lincons1(Environment v, boolean sat)
public Lincons1(int k, Linexpr1 e)
e is copied.
public Lincons1(int k, Linexpr1 e, Scalar s)
e is copied, s is referenced.
public Lincons1(Lincons1 c)
The left member expression and the optional scalar are copied.
public Lincons1(Environment e, Lincons0 x)
All coefficients are copied.
The environment must be large enough for all variables in x.
public static Lincons1 make(Environment v, Lincons0 x)
The level 0 constraint should no longer be used afterwards.
public void setCst(Coeff c)
The coefficient is copied.
public void setCoeff(java.lang.String var, Coeff c)
public void setCoeff(Linterm1[] c)
All coefficients are copied.
public void setKind(int k)
public void setScalar(Scalar s)
public Environment getEnvironment()
public int getKind()
public Scalar getScalar()
public Lincons0 getLincons0()
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.
public Coeff getCst()
public Linterm1[] getLinterms()
Linexpr1.getLinterms()
public Coeff[] getCoeffs()
Linexpr1.getCoeffs()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean isSparse()
public boolean isInteger()
public boolean isReal()
public boolean isLinear()
public boolean isQuasilinear()
public boolean isUnsat()
Returns true if the constraint has the form b >= 0 or [a,b] >= 0 with b negative.
public boolean isEqual(Lincons1 x)
public void minimize()
Linexpr0.minimize()
public void extendEnvironment(Environment e)
e must be a super-environment of that of this.
public Lincons1 extendEnvironmentCopy(Environment e)
e must be a super-environment of that of this.
this is not modified.
public Lincons1 clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object