Interface ConstraintStream
-
- All Known Subinterfaces:
BiConstraintStream<A,B>
,QuadConstraintStream<A,B,C,D>
,TriConstraintStream<A,B,C>
,UniConstraintStream<A>
public interface ConstraintStream
A constraint stream is a declaration on how to matchone
,two
or more objects. Constraint streams are similar to a declaration of a JDKStream
or an SQL query, but they support incremental score calculation andScoreManager.explainScore(Object)
score justification}.An object that passes through constraint streams is called a fact. It's either a
problem fact
or aplanning entity
.A constraint stream is typically created with
ConstraintFactory.forEach(Class)
orUniConstraintStream.join(UniConstraintStream, BiJoiner)
by joining another constraint stream}. Constraint streams form a directed, non-cyclic graph, with multiple start nodes (which listen to fact changes) and one end node perConstraint
(which affect theScore
).Throughout this documentation, we will be using the following terminology:
- Constraint Stream
- A chain of different operations, originated by
ConstraintFactory.forEach(Class)
(or similar methods) and terminated by a penalization or reward operation. - Operation
- Operations (implementations of
ConstraintStream
) are parts of a constraint stream which mutate it. They may remove tuples from further evaluation, expand or contract streams. Every constraint stream has a terminal operation, which is either a penalization or a reward. - Fact
- Object instance entering the constraint stream.
- Genuine Fact
- Fact that enters the constraint stream either through a from(...) call or through a join(...) call.
Genuine facts are either planning entities (see
PlanningEntity
) or problem facts (seeProblemFactProperty
orProblemFactCollectionProperty
). - Inferred Fact
- Fact that enters the constraint stream through a computation. This would typically happen through an operation such as groupBy(...).
- Tuple
- A collection of facts that the constraint stream operates on, propagating them from operation to
operation.
For example,
UniConstraintStream
operates on single-fact tuples {A} andBiConstraintStream
operates on two-fact tuples {A, B}. Putting facts into a tuple implies a relationship exists between these facts. - Match
- Match is a tuple that reached the terminal operation of a constraint stream and is therefore either penalized or rewarded.
- Cardinality
- The number of facts in a tuple. Uni constraint streams have a cardinality of 1, bi constraint streams have a cardinality of 2, etc.
- Conversion
- An operation that changes the cardinality of a constraint stream. This typically happens through join(...) or a groupBy(...) operations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description ConstraintFactory
getConstraintFactory()
TheConstraintFactory
that build this.Constraint
impact(String constraintPackage, String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.impact(Score)
and equivalent bi/tri/...Constraint
impact(String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.impact(Score)
and equivalent bi/tri/...Constraint
penalize(String constraintPackage, String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.penalize(Score)
and equivalent bi/tri/...Constraint
penalize(String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.penalize(Score)
and equivalent bi/tri/...Constraint
penalizeConfigurable(String constraintName)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.penalizeConfigurable()
and equivalent bi/tri/...Constraint
penalizeConfigurable(String constraintPackage, String constraintName)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.penalizeConfigurable()
and equivalent bi/tri/...Constraint
reward(String constraintPackage, String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.reward(Score)
and equivalent bi/tri/...Constraint
reward(String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.reward(Score)
and equivalent bi/tri/...Constraint
rewardConfigurable(String constraintName)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.rewardConfigurable()
and equivalent bi/tri/...Constraint
rewardConfigurable(String constraintPackage, String constraintName)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.rewardConfigurable()
and equivalent bi/tri/...
-
-
-
Method Detail
-
getConstraintFactory
ConstraintFactory getConstraintFactory()
TheConstraintFactory
that build this.- Returns:
- never null
-
penalize
@Deprecated(forRemoval=true) Constraint penalize(String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.penalize(Score)
and equivalent bi/tri/... overloads.Negatively impact theScore
: subtract the constraintWeight for each match.To avoid hard-coding the constraintWeight, to allow end-users to tweak it, use
penalizeConfigurable(String)
and aConstraintConfiguration
instead.The
Constraint.getConstraintPackage()
defaults to the package of thePlanningSolution
class.- Parameters:
constraintName
- never null, shows up inConstraintMatchTotal
during score justificationconstraintWeight
- never null- Returns:
- never null
-
penalize
@Deprecated(forRemoval=true) Constraint penalize(String constraintPackage, String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.penalize(Score)
and equivalent bi/tri/... overloads.As defined bypenalize(String, Score)
.- Parameters:
constraintPackage
- never nullconstraintName
- never nullconstraintWeight
- never null- Returns:
- never null
-
penalizeConfigurable
@Deprecated(forRemoval=true) Constraint penalizeConfigurable(String constraintName)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.penalizeConfigurable()
and equivalent bi/tri/... overloads.Negatively impact theScore
: subtract theConstraintWeight
for each match.The constraintWeight comes from an
ConstraintWeight
annotated member on theConstraintConfiguration
, so end users can change the constraint weights dynamically. This constraint may be deactivated if theConstraintWeight
is zero. If there is noConstraintConfiguration
, usepenalize(String, Score)
instead.The
Constraint.getConstraintPackage()
defaults toConstraintConfiguration.constraintPackage()
.- Parameters:
constraintName
- never null, shows up inConstraintMatchTotal
during score justification- Returns:
- never null
-
penalizeConfigurable
@Deprecated(forRemoval=true) Constraint penalizeConfigurable(String constraintPackage, String constraintName)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.penalizeConfigurable()
and equivalent bi/tri/... overloads.As defined bypenalizeConfigurable(String)
.- Parameters:
constraintPackage
- never nullconstraintName
- never null- Returns:
- never null
-
reward
@Deprecated(forRemoval=true) Constraint reward(String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.reward(Score)
and equivalent bi/tri/... overloads.Positively impact theScore
: add the constraintWeight for each match.To avoid hard-coding the constraintWeight, to allow end-users to tweak it, use
penalizeConfigurable(String)
and aConstraintConfiguration
instead.The
Constraint.getConstraintPackage()
defaults to the package of thePlanningSolution
class.- Parameters:
constraintName
- never null, shows up inConstraintMatchTotal
during score justificationconstraintWeight
- never null- Returns:
- never null
-
reward
@Deprecated(forRemoval=true) Constraint reward(String constraintPackage, String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.reward(Score)
and equivalent bi/tri/... overloads.As defined byreward(String, Score)
.- Parameters:
constraintPackage
- never nullconstraintName
- never nullconstraintWeight
- never null- Returns:
- never null
-
rewardConfigurable
@Deprecated(forRemoval=true) Constraint rewardConfigurable(String constraintName)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.rewardConfigurable()
and equivalent bi/tri/... overloads.Positively impact theScore
: add theConstraintWeight
for each match.The constraintWeight comes from an
ConstraintWeight
annotated member on theConstraintConfiguration
, so end users can change the constraint weights dynamically. This constraint may be deactivated if theConstraintWeight
is zero. If there is noConstraintConfiguration
, usereward(String, Score)
instead.The
Constraint.getConstraintPackage()
defaults toConstraintConfiguration.constraintPackage()
.- Parameters:
constraintName
- never null, shows up inConstraintMatchTotal
during score justification- Returns:
- never null
-
rewardConfigurable
@Deprecated(forRemoval=true) Constraint rewardConfigurable(String constraintPackage, String constraintName)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.rewardConfigurable()
and equivalent bi/tri/... overloads.As defined byrewardConfigurable(String)
.- Parameters:
constraintPackage
- never nullconstraintName
- never null- Returns:
- never null
-
impact
@Deprecated(forRemoval=true) Constraint impact(String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.impact(Score)
and equivalent bi/tri/... overloads.Positively or negatively impact theScore
by the constraintWeight for each match.Use
penalize(...)
orreward(...)
instead, unless this constraint can both have positive and negative weights.The
Constraint.getConstraintPackage()
defaults to the package of thePlanningSolution
class.- Parameters:
constraintName
- never null, shows up inConstraintMatchTotal
during score justificationconstraintWeight
- never null- Returns:
- never null
-
impact
@Deprecated(forRemoval=true) Constraint impact(String constraintPackage, String constraintName, Score<?> constraintWeight)
Deprecated, for removal: This API element is subject to removal in a future version.PreferUniConstraintStream.impact(Score)
and equivalent bi/tri/... overloads.As defined byimpact(String, Score)
.- Parameters:
constraintPackage
- never nullconstraintName
- never nullconstraintWeight
- never null- Returns:
- never null
-
-