public class TypeConstraint extends Object implements IConstraint
IConstraint
on INode
. A IResource
needs to have the matching TypeQualification
in order to give service to said Node
.
Implementation example:
//Defining a Node
CapacityResource jack = new CapacityResource(
"JackEssenQualified",
51.45,
7.01667,
Duration.ofHours(10),
Quantities.getQuantity(1200, KILO(METRE)),
workingHours);
rep1.setCost(100, 1, 1);
// Defining a qualification and giving it to the Node
TypeQualification typeQualification1 = new TypeQualification();
typeQualification1.addType("plumbing");
jack.addQualification(typeQualification1);
opti.addElement(jack);
// Defining a Constraint
IConstraint typeConstraint = new TypeConstraint();
((TypeConstraint) typeConstraint).addType("plumbing");
typeConstraint.setIsHard(true);
Duration visitDuration = Duration.ofMinutes(20);
// Defining a Node and giving it the Constraint
TimeWindowGeoNode aachen =
new TimeWindowGeoNode("Aachen", 50.775346, 6.083887, weeklyOpeningHours, visitDuration, 1);
aachen.addConstraint(typeConstraint);
this.addElement(aachen);
Constructor and Description |
---|
TypeConstraint() |
Modifier and Type | Method and Description |
---|---|
void |
addType(String type) |
com.dna.jopt.assessment.costassessorrestriction.restrictionresult.IEntityRestrictionResult |
assessConstraint(IEntity en,
ILogicEntityRoute route,
INode node,
com.dna.jopt.assessment.costadjustment.IEntityCostAdjuster cad,
com.dna.jopt.assessment.costassessor.IEntityCostAssessor ca,
com.dna.jopt.framework.inputplausibility.properties.IPropertyProvider propertyProvider,
boolean resultRequested)
Assesses the route, checking if the appropriate
qualifications for the constraints are present. |
String |
getTitle()
Gets the title of the constraint.
|
List<String> |
getTypes() |
boolean |
hasMembers() |
boolean |
isHard()
Checks the parameter or directly returns
true where this must be the case. |
boolean |
isSatisfied(com.dna.jopt.assessment.costassessor.IEntityCostAssessor ca,
INode node,
ILogicEntityRoute route)
Filters out hard constraint mismatches by checking whether a
Node demands a Qualification as a hard constraint but the Resource does not provide this one. |
void |
setIsHard(boolean isHard)
Sets the constraint to
hard if the respective parameter is given or returns an IllegalStateException if this is expected but not the case. |
void |
setTypes(List<String> types) |
String |
toString() |
public static final String MY_TITLE
public String getTitle()
IConstraint
getTitle
in interface IConstraint
public boolean isHard()
IConstraint
true
where this must be the case.isHard
in interface IConstraint
public void setIsHard(boolean isHard)
IConstraint
hard
if the respective parameter is given or returns an IllegalStateException
if this is expected but not the case.setIsHard
in interface IConstraint
isHard
- the boolean to be setpublic boolean isSatisfied(com.dna.jopt.assessment.costassessor.IEntityCostAssessor ca, INode node, ILogicEntityRoute route)
IConstraint
Node
demands a Qualification
as a hard constraint
but the Resource
does not provide this one.
The idea is to have only soft constraints
problems in the optimisation which can get
solved by adding cost.isSatisfied
in interface IConstraint
ca
- the iEntityCostAssessornode
- the iNoderoute
- the iLogicEntityRouteTrue
means no problems detectedpublic com.dna.jopt.assessment.costassessorrestriction.restrictionresult.IEntityRestrictionResult assessConstraint(IEntity en, ILogicEntityRoute route, INode node, com.dna.jopt.assessment.costadjustment.IEntityCostAdjuster cad, com.dna.jopt.assessment.costassessor.IEntityCostAssessor ca, com.dna.jopt.framework.inputplausibility.properties.IPropertyProvider propertyProvider, boolean resultRequested)
IConstraint
qualifications
for the constraints
are present.
The boolean true
saves the data.
assessConstraint
in interface IConstraint
en
- entityroute
- the iLogicEntityRoutenode
- nodecad
- iEntityCostAdjusterca
- capropertyProvider
- iPropertyProviderresultRequested
- the boolean whether to save the results of the routepublic void addType(String type)
public boolean hasMembers()
hasMembers
in interface IConstraint
Copyright © 2017–2023 DNA Evolutions GmbH. All rights reserved.