Class PCSTNU
- Author:
- posenato
-
Nested Class Summary
Nested classes/interfaces inherited from class CSTNU
CSTNU.CSTNUCheckStatusModifier and TypeClassDescriptionstatic classA simple class to represent the status of the checking algorithm during an execution.Nested classes/interfaces inherited from class AbstractCSTN
AbstractCSTN.CheckAlgorithm, AbstractCSTN.CSTNCheckStatus, AbstractCSTN.DCSemantics, AbstractCSTN.EdgesToCheck<E>, AbstractCSTN.NodesToCheckModifier and TypeClassDescriptionstatic enumOnly for stating which kind of DC checking algorithms have been implemented so far.static classRepresents the status of a CSTN-checking algorithm during an execution.static enumValue for dcSemanticsstatic classAbstractCSTN.EdgesToCheck<E extends Edge>A simple class to maintain the set of edges to check in the following phase.static classActs as a queue and a set. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final Loggerlogger(package private) it.unimi.dsi.fastutil.objects.ObjectArrayList<LabeledNode> The set of parameter nodesstatic final StringVersion of the classFields inherited from class CSTNU
activationNode, contingentAlsoAsOrdinary, lowerContingentEdgeModifier and TypeFieldDescription(package private) it.unimi.dsi.fastutil.objects.Object2ObjectMap<LabeledNode, LabeledNode> Utility map that returns the activation time point (node) associated with a contingent link given the contingent time point, i.e., contingent link A ===> C determines the entry (C, A) in this map.(package private) booleanRepresent contingent links also as ordinary constraints.(package private) it.unimi.dsi.fastutil.objects.Object2ObjectMap<LabeledNode, CSTNUEdge> Utility map that returns the edge containing the lower-case constraint of a contingent link given the contingent time point.Fields inherited from class AbstractCSTN
checkStatus, cleanCheckedInstance, FILE_NAME_SUFFIX, fInput, fOutput, g, gCheckedCleaned, horizon, maxWeight, propagationOnlyToZ, reactionTime, timeOut, versionReq, withNodeLabels, ZERO_NODE_NAMEModifier and TypeFieldDescription(package private) AbstractCSTN.CSTNCheckStatusCheck status(package private) booleanIf true, after a check, the resulting graph is cleaned: all empty edges or labeled values containing unknown literals are removed.(package private) static StringSuffix for file name(package private) FileThe input file containing the CSTN graph in GraphML format.(package private) FileOutput file where to write the XML representing the CSTN graph after a check.(package private) TemporalConstraintGraph<CSTNUEdge> Input graph.(package private) TemporalConstraintGraph<CSTNUEdge> The graph obtained by a check and the cleaning action.(package private) intHorizon value.(package private) intThe absolute value of the max negative weight was determined during the initialization phase.(package private) booleanCheck using the full set of rules R0, qR0, R3, qR3, LP, qLP or the reduced set qR0, qR3, LP.(package private) intWD2.2 epsilon value, also called `reaction time` in ICAPS 18.(package private) intTimeout in seconds for the check.(package private) booleanSoftware Version.(package private) booleanIf false, node labels are ignored during the check.static final StringThe name for the initial node. -
Constructor Summary
ConstructorsConstructorDescriptionPCSTNU()Creates a PCSTNU with an empty graph using the sparse backend by default.PCSTNU(boolean useDenseGraph) Creates a PCSTNU with an empty, newly created graph.PCSTNU(TemporalConstraintGraph<CSTNUEdge> graph) PCSTNU(TemporalConstraintGraph<CSTNUEdge> graph, int giveTimeOut) -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks and initializes the CSTN instance represented by graphg.(package private) final booleanlabeledCrossLowerCaseRule(LabeledNode nA, LabeledNode nC, LabeledNode nX, CSTNUEdge eAC, CSTNUEdge eCX, CSTNUEdge eAX) Apply B and B-parameter rules of the paper about Parameter-CSTNU.(package private) final booleanlabelPropagation(LabeledNode nX, LabeledNode nY, LabeledNode nW, CSTNUEdge eXY, CSTNUEdge eYW, CSTNUEdge eXW) Apply A, A-Parameter, and C rules of the paper about Parameter-CSTNU.static voidReads a PCSTNU file and checks it.oneStepDynamicControllability(AbstractCSTN.EdgesToCheck<CSTNUEdge> edgesToCheck, Instant timeoutInstant) Executes one step of the dynamic controllability check.oneStepDynamicControllabilityLimitedToZ(AbstractCSTN.EdgesToCheck<CSTNUEdge> edgesToCheck, Instant timeoutInstant) Executes one step of the dynamic controllability check, considering only a pair of edges going to/from Z or parameter nodes.Methods inherited from class CSTNU
checkAndManageIfNewLabeledValueIsANegativeLoop, checkWellDefinitionProperty1and3, dynamicConsistencyCheck, dynamicControllabilityCheck, getCheckStatus, isContingentAlsoAsOrdinary, labelModificationqR0, labelModificationqR3, lowerCaseValueAsString, mainConditionForRestrictedLP, mainConditionForSkippingInR0qR0, reset, setContingentAlsoAsOrdinary, upperCaseValueAsString, zLabeledLetterRemovalRuleModifier and TypeMethodDescription(package private) static booleancheckAndManageIfNewLabeledValueIsANegativeLoop(int value, LabeledNode source, LabeledNode dest, BasicCSTNUEdge newEdge, AbstractCSTN.CSTNCheckStatus status) Just to check if a new labeled value is negative, its label has no unknown literals, and it is in a self-loop.(package private) booleancheckWellDefinitionProperty1and3(LabeledNode source, LabeledNode destination, CSTNUEdge e, boolean hasToBeFixed) Calls and then checks upper and lower case values.Checks the dynamic consistency (DC) of a CSTN instance within timeout seconds.Checks the dynamic controllability (DC) of the given network (seeCSTNU(TemporalConstraintGraph)orAbstractCSTN.setG(TemporalConstraintGraph)).final CSTNU.CSTNUCheckStatusGetter for the fieldcheckStatus, the status of a checking algorithm.boolean(package private) final booleanlabelModificationqR0(LabeledNode nObs, CSTNUEdge ePZ) Implements the zqR0 rule assuming instantaneous reaction and a streamlined network.(package private) final booleanlabelModificationqR3(LabeledNode nS, CSTNUEdge eSZ) Implements the qR3* rule assuming instantaneous reaction and a streamlined network.(package private) static StringlowerCaseValueAsString(ALabel nodeName, int value, Label label) static booleanmainConditionForRestrictedLP(int u, int ignoredV) IR Semantics(package private) final booleanIR Semantics Returns true ifAbstractCSTN.labelModificationR0qR0(LabeledNode, LabeledNode, E)method has to not apply.voidreset()Resets all internal structuresfinal voidsetContingentAlsoAsOrdinary(boolean givenContingentAlsoAsOrdinary) Setter for the fieldcontingentAlsoAsOrdinary.(package private) static StringupperCaseValueAsString(ALabel nodeName, int value, Label label) (package private) final booleanLabeled LetterRemoval (zLr) and (zLr*)Methods inherited from class AbstractCSTN
addUpperBounds, checkWellDefinitionProperties, coreCSTNInitAndCheck, getCheckedGraph, getEdgeFromObserversToNode, getfOutput, getG, getGChecked, getGCheckedAsGraphML, getGraph, getMaxWeight, getReactionTime, getVersionAndCopyright, isOutputCleaned, isWithNodeLabels, labelModificationR0qR0, labelModificationR0qR0Core, mainConditionForSkippingInR3qR3, makeAlphaBetaGammaPrime4R3, makeAlphaPrime, makeBetaGammaDagger4qR3, makeNewEdge, manageParameters, newValueInR3qR3, pairAsString, recordCheckOutcome, removeChildrenOfUnknown, saveGraphToFile, setfOutput, setG, setOutputCleaned, setPropagationOnlyToZ, setWithNodeLabelsModifier and TypeMethodDescription(package private) final voidThe upper bounds from Z to each node have to be set after the horizon is determined.(package private) final booleancheckWellDefinitionProperties.(package private) final voidMakes the CSTN well-definedness check and initialization.final TemporalConstraintGraph<CSTNUEdge> Getter for the resulting checked graph, without copying or converting it.(package private) final it.unimi.dsi.fastutil.objects.ObjectList<CSTNUEdge> Determines the set of edges P?Getter for the fieldfOutput.getG()Deprecated.Deprecated.useAbstractCSTN.getCheckedGraph()in algorithms; this adapter is only for JUNG/GraphML boundaries.Helper method for having the graph obtained byAbstractCSTN.getCheckedGraph()in GraphML format.final TemporalConstraintGraph<CSTNUEdge> getGraph()Getter for the fieldg, the input graph, without copying or converting it.final intGetter for the fieldmaxWeight.final intGetter for the fieldreactionTime.final Stringbooleanboolean(package private) final booleanlabelModificationR0qR0(LabeledNode nObs, LabeledNode nX, CSTNUEdge eObsX) Applies rule R0/qR0: label containing a proposition that can be decided only in the future is simplified by removing such a proposition.(package private) final LabellabelModificationR0qR0Core(LabeledNode nP, LabeledNode nX, Label alpha, int w) Execute the core ofAbstractCSTN.labelModificationR0qR0(LabeledNode, LabeledNode, CSTNEdge).(package private) booleanmainConditionForSkippingInR3qR3(int w, LabeledNode nD) Returns true ifCSTN.labelModificationR3qR3(LabeledNode, LabeledNode, CSTNEdge)method has to not apply.(package private) final LabelmakeAlphaBetaGammaPrime4R3(LabeledNode nS, LabeledNode nD, LabeledNode nObs, char observed, Label labelFromObs, Label labelToClean) A simple method to determine the label "αβγ" for the ruleCSTN.labelModificationR3qR3(LabeledNode, LabeledNode, CSTNEdge).(package private) final LabelmakeAlphaPrime(LabeledNode nX, LabeledNode nObs, char observed, Label labelFromObs) Simple method to determine theα'to use in rules R0 and in rule qR0.(package private) final LabelmakeBetaGammaDagger4qR3(LabeledNode nS, LabeledNode nObs, char observed, Label labelFromObs, Label labelToClean) Simple method to determine the label (β*γ)† to use in rules qR3*CSTN.labelModificationR3qR3(LabeledNode, LabeledNode, CSTNEdge).(package private) final CSTNUEdgemakeNewEdge(String name, Edge.ConstraintType type) Create an edge, ensuring that its name is unique in the graph 'g'.(package private) final booleanmanageParameters(String[] args) Simple method to manage command line parameters using the "args4j" library.(package private) intnewValueInR3qR3(int edgeValue, int obsEdgeValue) Determines the new value that rules R3 and qR3 (see Table 1 in the ICAPS 2016 paper) must add.(package private) static StringpairAsString(Label label, int value) protected final voidrecordCheckOutcome(CheckOutcome.Kind kind, boolean successful) Records the verdict of a completed check on bothAbstractCSTN.gand, when it exists and is notgitself, onAbstractCSTN.gCheckedCleaned.(package private) final LabelReturns a new label removing all children of possibly present unknown literals inl.final voidHelper method to make it easier to store the resulting graph during a check.final voidsetfOutput(File fileOutput) final voidsetG(TemporalConstraintGraph<CSTNUEdge> graph) Considers the given graph as the graph to check, without copying or converting it (the graph will be modified).final voidsetOutputCleaned(boolean clean) Set to true for having the result graph cleaned of empty edges and labeled values having unknown literals.final voidsetPropagationOnlyToZ(boolean propagationOnlyToZ1) Setter for the fieldpropagationOnlyToZ.final voidsetWithNodeLabels(boolean withNodeLabels1)
-
Field Details
-
VERSIONandDATE
-
LOG
logger -
parameterNodes
it.unimi.dsi.fastutil.objects.ObjectArrayList<LabeledNode> parameterNodesThe set of parameter nodes
-
-
Constructor Details
-
PCSTNU
- Parameters:
graphXML- an XML description of a parameterized PCSTNU instance- Throws:
IOException- any problem in reading the XMLParserConfigurationException- any problem in the XML formatSAXException- any problem in the XML format
-
PCSTNU
- Parameters:
graph- a parameterized CSTNU, without copying or converting it
-
PCSTNU
- Parameters:
graph- a parameterized CSTNU, without copying or converting itgiveTimeOut- maximum duration (in seconds) for the DC checking.
-
PCSTNU
public PCSTNU()Creates a PCSTNU with an empty graph using the sparse backend by default. -
PCSTNU
public PCSTNU(boolean useDenseGraph) Creates a PCSTNU with an empty, newly created graph.- Parameters:
useDenseGraph- true to use the dense backend (DenseTCGraph); false to use the sparse backend (SparseTCGraph).
-
-
Method Details
-
main
public static void main(String[] args) throws IOException, ParserConfigurationException, SAXException Reads a PCSTNU file and checks it.- Parameters:
args- an array ofStringobjects.- Throws:
IOException- if any.ParserConfigurationException- if any.SAXException- if any.
-
initAndCheck
Checks and initializes the CSTN instance represented by graphg. The check is made byAbstractCSTN.coreCSTNInitAndCheck().Since many DC checking algorithms are complete if and only if the CSTN instance contains an upper bound to the distance from Z (the first node) for each node, this method also calls
AbstractCSTN.addUpperBounds()for adding such bounds as constraints between Z and each node.Calls and then checks all contingent links. This method works only with streamlined instances!
Calls and then checks all constraints about parameter nodes. This method works only with streamlined instances!
- Overrides:
initAndCheckin classCSTNU- Throws:
WellDefinitionException- if the initial graph is not well-defined. We preferred to throw an exception instead of returning a negative status to stress that any further operation cannot be made on this instance.- See Also:
-
oneStepDynamicControllability
public CSTNU.CSTNUCheckStatus oneStepDynamicControllability(AbstractCSTN.EdgesToCheck<CSTNUEdge> edgesToCheck, Instant timeoutInstant) Description copied from class:CSTNUExecutes one step of the dynamic controllability check.Before the first execution of this method, it is necessary to execute
CSTNU.initAndCheck().- Overrides:
oneStepDynamicControllabilityin classCSTNU- Parameters:
edgesToCheck- set of edges that have to be checked.timeoutInstant- the time instant limit allowed for the computation.- Returns:
- the updated status (for convenience, it is not necessary because it returns the same parameter status).
-
oneStepDynamicControllabilityLimitedToZ
public CSTNU.CSTNUCheckStatus oneStepDynamicControllabilityLimitedToZ(AbstractCSTN.EdgesToCheck<CSTNUEdge> edgesToCheck, Instant timeoutInstant) Executes one step of the dynamic controllability check, considering only a pair of edges going to/from Z or parameter nodes.The name is limited to Z because it is inherited from CSTNU, but such a method also calls others that consider parameter nodes as Z nodes.
Before the first execution of this method, it is necessary to execute
initAndCheck().Note: this version is not optimized with respect to the number of times and edge is considered at each call. Future versions will improve this aspect.
- Overrides:
oneStepDynamicControllabilityLimitedToZin classCSTNU- Parameters:
edgesToCheck- set of edges that have to be checked.timeoutInstant- the time instant limit allowed for the computation.- Returns:
- the updated status (for convenience, it is not necessary because it returns the same parameter status).
-
labelPropagation
final boolean labelPropagation(LabeledNode nX, LabeledNode nY, LabeledNode nW, CSTNUEdge eXY, CSTNUEdge eYW, CSTNUEdge eXW) Apply A, A-Parameter, and C rules of the paper about Parameter-CSTNU.1) CASE A ℵ:v,β u,α W==Z <------------ Y <------------ X adds ℵ:u+v,𝛾 Z <------------------------------X 𝛾=αβ has to be consistent and u+v < 0. ℵ can be empty. If X is a parameter, set ℵ and 𝛾 empty in the generated edge 2) CASE A-Parameter v,β ℵ:u,α W==P <------------ Y <------------ X adds ℵ:u+v,𝛾 P <------------------------------X P is a parameter, 𝛾=αβ has to be consistent. ℵ can be empty. If X is a parameter or Z, set ℵ and 𝛾 empty in the generated edge 2) CASE C ℵ:v,β C:u,α Z <------------ Y <------------ C adds Cℵ:u+v,αβ Z <------------------------------C if u+v < 0 and αβ is consistent ℵ can be empty.- Overrides:
labelPropagationin classCSTNU- Parameters:
nX- nodenY- nodenW- nodeeXY- CANNOT BE NULLeYW- CANNOT BE NULLeXW- CANNOT BE NULL- Returns:
- true if a reduction is applied at least
-
labeledCrossLowerCaseRule
final boolean labeledCrossLowerCaseRule(LabeledNode nA, LabeledNode nC, LabeledNode nX, CSTNUEdge eAC, CSTNUEdge eCX, CSTNUEdge eAX) Apply B and B-parameter rules of the paper about Parameter-CSTNU.1) Case B
ℵ:v,β c:u,α Z <------------ C <------------ A adds ℵ:u+v,αβ Z <----------------------------A Conditions: αβ∈P*, C ∉ ℵ, u+v < 02) Case B-parameter
v,β c:u,α X <------------ C <------------ A adds u+v,αβ X <----------------------------A X is a parameter node. Conditions: αβ∈P*Since it is assumed that L(C) L (A)=α, there is only ONE lower-case labeled value u,c,α! The name is inherited from CSTNU.
- Overrides:
labeledCrossLowerCaseRulein classCSTNU- Parameters:
nA- nodenC- nodenX- nodeeAC- CANNOT BE NULLeCX- CANNOT BE NULLeAX- CANNOT BE NULL- Returns:
- true if the rule has been applied.
-
AbstractCSTN.getGraph()in algorithms; this adapter is only for JUNG/GraphML boundaries.