Class TypeConstraint
java.lang.Object
com.dna.jopt.member.unit.condition.type.TypeConstraint
- All Implemented Interfaces:
IConstraint,Serializable
This class allows setting
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);
- Since:
- 13/08/2019
- Version:
- 09/09/2019
- Author:
- DNA
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcom.dna.jopt.assessment.costassessorrestriction.restrictionresult.IEntityRestrictionResultassessConstraint(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 appropriatequalificationsfor theconstraintsare present.getTitle()Gets the title of the constraint.getTypes()booleanbooleanisHard()Checks the parameter or directly returnstruewhere this must be the case.booleanisSatisfied(com.dna.jopt.assessment.costassessor.IEntityCostAssessor ca, INode node, ILogicEntityRoute route) Filters out hard constraint mismatches by checking whether aNodedemands aQualificationas ahard constraintbut theResourcedoes not provide this one.voidsetIsHard(boolean isHard) Sets the constraint tohardif the respective parameter is given or returns anIllegalStateExceptionif this is expected but not the case.voidtoString()
-
Field Details
-
MY_TITLE
- See Also:
-
-
Constructor Details
-
TypeConstraint
public TypeConstraint()
-
-
Method Details
-
getTitle
Description copied from interface:IConstraintGets the title of the constraint.- Specified by:
getTitlein interfaceIConstraint- Returns:
- the title
-
isHard
public boolean isHard()Description copied from interface:IConstraintChecks the parameter or directly returnstruewhere this must be the case.- Specified by:
isHardin interfaceIConstraint- Returns:
- the value of the checked boolean
-
setIsHard
public void setIsHard(boolean isHard) Description copied from interface:IConstraintSets the constraint tohardif the respective parameter is given or returns anIllegalStateExceptionif this is expected but not the case.- Specified by:
setIsHardin interfaceIConstraint- Parameters:
isHard- the boolean to be set
-
isSatisfied
public boolean isSatisfied(com.dna.jopt.assessment.costassessor.IEntityCostAssessor ca, INode node, ILogicEntityRoute route) Description copied from interface:IConstraintFilters out hard constraint mismatches by checking whether aNodedemands aQualificationas ahard constraintbut theResourcedoes not provide this one. The idea is to have onlysoft constraintsproblems in the optimisation which can get solved by adding cost.- Specified by:
isSatisfiedin interfaceIConstraint- Parameters:
ca- the iEntityCostAssessornode- the iNoderoute- the iLogicEntityRoute- Returns:
- the boolean whether the route is satisfied.
Truemeans no problems detected
-
assessConstraint
public 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) Description copied from interface:IConstraintAssesses the route, checking if the appropriatequalificationsfor theconstraintsare present.The
boolean truesaves the data.- Specified by:
assessConstraintin interfaceIConstraint- Parameters:
en- entityroute- the iLogicEntityRoutenode- nodecad- iEntityCostAdjusterca- capropertyProvider- iPropertyProviderresultRequested- the boolean whether to save the results of the route- Returns:
- Entity Restriction Result
-
toString
-
addType
-
getTypes
-
setTypes
-
hasMembers
public boolean hasMembers()- Specified by:
hasMembersin interfaceIConstraint
-