Class OSTNU
This class implementation considers instantaneous reactions and checks the agile controllability assuming that the network can be executed adopting an early execution strategy.
At 2024-02-14, the agile controllability is checked propagating a modified version of Morris' rules:
- No case rule
- new upper case rule
- new lower case rule
- cross case rule
- label removal rule
- oracle rule
Each oracle is associated to a specific contingent node.
So, if there is a contingent node 'C' and an oracle 'OC' for it, node OC ha in its observation field the value 'C'.
New upper/lower case rules and oracle rule determines new rules labeled by the fact the oracle is involved or not.
In particular, each value determined by oracle rule involving an oracle 'OC' having observation field = 'C'
is labeled by 'C'. Each value determined by new lower/upper rule that involve contingent node 'C' is labeled by '¬C'.
In other words, label 'C' and label '¬C' represent two possible values generated considering contingent node 'C'
that cannot be combined because they are alternative. 'C' and '¬C' can be considered literals of a boolean
proposition 'C'.
Other rules, consider and propagate only values having label that are consistent, i.e., labels that not present
opposite literals.
Constraint values (represented as edge values) are integers.
- Version:
- $Rev: 840 $
- Author:
- Roberto Posenato
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Simple class to represent the status of the checking algorithm during an execution.
controllability = super.consistency
.Nested classes/interfaces inherited from class it.univr.di.cstnu.algorithms.AbstractCSTN
AbstractCSTN.CheckAlgorithm, AbstractCSTN.CSTNCheckStatus, AbstractCSTN.DCSemantics, AbstractCSTN.EdgesToCheck<E extends Edge>, AbstractCSTN.NodesToCheck
-
Field Summary
Modifier and TypeFieldDescription(package private) it.unimi.dsi.fastutil.objects.Object2ObjectMap
<LabeledNode, LabeledNode> Utility map that returns the activation time point (node) associated to a contingent link given the contingent time point, i.e., contingent link A===>C determines the entry (C,A) in this map.(package private) OSTNU.OSTNUCheckStatus
Agile status(package private) boolean
Represent contingent links also as ordinary constraints.(package private) it.unimi.dsi.fastutil.objects.Object2ObjectMap
<LabeledNode, OSTNUEdgePluggable> Utility map that return the edge containing the lower case constraint of a contingent link given the contingent time point.(package private) it.unimi.dsi.fastutil.objects.Object2ObjectMap
<LabeledNode, LabeledNode> Utility map that returns the oracle node O_C associated to a contingent node C.static final String
Version of the classFields inherited from class it.univr.di.cstnu.algorithms.AbstractCSTN
cleanCheckedInstance, FILE_NAME_SUFFIX, fInput, fOutput, g, gCheckedCleaned, horizon, maxWeight, propagationOnlyToZ, reactionTime, timeOut, versionReq, withNodeLabels, ZERO_NODE_NAME
-
Constructor Summary
ConstructorDescriptionOSTNU()
Default constructor, package use only!OSTNU
(TNGraph<OSTNUEdgePluggable> graph) Constructor for CSTNUOSTNU
(TNGraph<OSTNUEdgePluggable> graph, int giveTimeOut) Constructor for CSTNUHelper constructor for CSTNU. -
Method Summary
Modifier and TypeMethodDescriptionChecks the agile controllability (AC) of the given network (seeOSTNU(TNGraph)
orAbstractCSTN.setG(TNGraph)
).
If the network is AC, it determines all the minimal ranges for the constraints.(package private) boolean
checkAndManageIfNewLabeledValueIsANegativeLoop
(int value, Label label, LabeledNode source, LabeledNode destination, OSTNUEdgePluggable newEdge) Checks if a new labeled value is negative and represents a negative cycle.Checks the dynamic consistency (DC) of a CSTN instance within timeout seconds.(package private) Label
getLabel4ValueInvolvingContingent
(LabeledNode contingent, LabeledNode node, boolean straight) void
Checks and initializes the CSTN instance represented by graphg
.(package private) boolean
Determines the minimal distance between all pairs of vertexes of the given graph if the graph is consistent, i.e., it does not contain any negative cycles.(package private) void
labeledCrossCaseRule
(LabeledNode nA, LabeledNode nC, LabeledNode nX, OSTNUEdgePluggable eAC, OSTNUEdgePluggable eCX, OSTNUEdgePluggable eAX) Labeled Cross Case Rule(package private) void
labeledLetterRemovalRule
(LabeledNode nX, LabeledNode nA, OSTNUEdgePluggable eXA) Labeled Letter Removal(package private) void
labeledLowerCaseRule
(LabeledNode nA, LabeledNode nC, LabeledNode nX, OSTNUEdgePluggable eAC, OSTNUEdgePluggable eCX, OSTNUEdgePluggable eAX) Labeled Lower Case Rule(package private) void
labeledOracleRule
(LabeledNode nA, LabeledNode nC, LabeledNode nX, OSTNUEdgePluggable eAC, OSTNUEdgePluggable eCX, OSTNUEdgePluggable eAX) Oracle rule.(package private) void
labeledPropagationRule
(LabeledNode nX, LabeledNode nY, LabeledNode nW, OSTNUEdgePluggable eXY, OSTNUEdgePluggable eYW, OSTNUEdgePluggable eXW) Applies 'labeled no case' or 'labeled upper case propagation' rules.(package private) void
labeledUpperCaseRule
(LabeledNode nX, LabeledNode nC, LabeledNode nA, OSTNUEdgePluggable eXC, OSTNUEdgePluggable eCA, OSTNUEdgePluggable eXA) Applies 'labeled upper case' rules.(package private) static String
lowerCaseValueAsString
(ALabel nodeName, int value, Label label) static void
Reads a CSTNU file and checks it.(package private) TNGraph
<OSTNUEdgePluggable> oneStepAgileControllability
(AbstractCSTN.EdgesToCheck<OSTNUEdgePluggable> edgesToCheck, Instant timeoutInstant) Executes one step of the agile controllability check.
Before the first execution of this method, it is necessary to executeinitAndCheck()
.(package private) void
Removes all labeled values belonging to negative scenarios.void
reset()
Resets all internal structures(package private) static String
upperCaseValueAsString
(ALabel nodeName, int value, Label label) Methods inherited from class it.univr.di.cstnu.algorithms.AbstractCSTN
addUpperBounds, checkWellDefinitionProperties, checkWellDefinitionProperty1and3, checkWellDefinitionProperty2, coreCSTNInitAndCheck, getCheckStatus, getEdgeFromObserversToNode, getfOutput, getG, getGChecked, getGCheckedAsGraphML, getMaxWeight, getMinimalDistanceGraph, getReactionTime, getVersionAndCopyright, isOutputCleaned, isWithNodeLabels, labelModificationR0qR0, labelModificationR0qR0Core, mainConditionForSkippingInR0qR0, mainConditionForSkippingInR3qR3, makeAlphaBetaGammaPrime4R3, makeAlphaPrime, makeBetaGammaDagger4qR3, makeNewEdge, manageParameters, newValueInR3qR3, pairAsString, removeChildrenOfUnknown, saveGraphToFile, setfOutput, setG, setOutputCleaned, setPropagationOnlyToZ, setWithNodeLabels
-
Field Details
-
VERSIONandDATE
-
checkStatus
OSTNU.OSTNUCheckStatus checkStatusAgile status -
activationNode
it.unimi.dsi.fastutil.objects.Object2ObjectMap<LabeledNode,LabeledNode> activationNodeUtility map that returns the activation time point (node) associated to a contingent link given the contingent time point, i.e., contingent link A===>C determines the entry (C,A) in this map. -
oracleNode
it.unimi.dsi.fastutil.objects.Object2ObjectMap<LabeledNode,LabeledNode> oracleNodeUtility map that returns the oracle node O_C associated to a contingent node C. The oracle node contain the contingent node name in its 'proposition' field. The map is (C, O_C). -
contingentAlsoAsOrdinary
boolean contingentAlsoAsOrdinaryRepresent contingent links also as ordinary constraints. -
lowerContingentEdge
it.unimi.dsi.fastutil.objects.Object2ObjectMap<LabeledNode,OSTNUEdgePluggable> lowerContingentEdgeUtility map that return the edge containing the lower case constraint of a contingent link given the contingent time point.
-
-
Constructor Details
-
OSTNU
Helper constructor for CSTNU.This constructor is useful for making easier the use of this class in environment like Node.js-Java
- Parameters:
graphXML
- the TNGraph to check in GraphML format- Throws:
IOException
- if any error occurs during the graphXML readingParserConfigurationException
- if graphXML contains character that cannot be parsedSAXException
- if graphXML is not valid
-
OSTNU
Constructor for CSTNU- Parameters:
graph
- TNGraph to checkgiveTimeOut
- timeout for the check in seconds
-
OSTNU
Constructor for CSTNU- Parameters:
graph
- TNGraph to check
-
OSTNU
OSTNU()Default constructor, package use only!
-
-
Method Details
-
lowerCaseValueAsString
-
main
public static void main(String[] args) throws IOException, ParserConfigurationException, SAXException Reads a CSTNU file and checks it.- Parameters:
args
- an array ofString
objects.- Throws:
IOException
- if any.ParserConfigurationException
- if any.SAXException
- if any.
-
upperCaseValueAsString
-
agileControllabilityCheck
Checks the agile controllability (AC) of the given network (seeOSTNU(TNGraph)
orAbstractCSTN.setG(TNGraph)
).
If the network is AC, it determines all the minimal ranges for the constraints.
During the execution of this method, the given network is modified.
If the check is successful, all constraints to node Z in the network are minimized; otherwise, the network contains a negative loop at least.
After a check,AbstractCSTN.getGChecked()
returns the graph resulting after the check andAbstractCSTN.getCheckStatus()
the result of the checking action with some statistics and the node with the negative loop is the network is NOT DC.
In any case, before returning, this method callAbstractCSTN.saveGraphToFile()
for saving the computed graph.- Returns:
- an
OSTNU.OSTNUCheckStatus
object containing the final status and some statistics about the executed checking. - Throws:
WellDefinitionException
- if any.
-
dynamicConsistencyCheck
Checks the dynamic consistency (DC) of a CSTN instance within timeout seconds. During the execution of this method, the given network is modified.
If the check is successful, all constraints to node Z in the network are minimized; otherwise, the network contains a negative loop at least.
After a check,AbstractCSTN.getGChecked()
returns the network determined by the check andAbstractCSTN.getCheckStatus()
the result of the checking action with some statistics and the node having the negative loop if the network is NOT DC.
In any case, before returning, this method callAbstractCSTN.saveGraphToFile()
for saving the computed graph. Wrapper method foragileControllabilityCheck()
- Specified by:
dynamicConsistencyCheck
in classAbstractCSTN<OSTNUEdgePluggable>
- Returns:
- the final status of the checking with some statistics.
- Throws:
WellDefinitionException
- 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 calls alsoAbstractCSTN.addUpperBounds()
for adding such bounds as constraints between Z and each node. Calls and, then, check all contingent links. This method works only with streamlined instances!- Overrides:
initAndCheck
in classAbstractCSTN<OSTNUEdgePluggable>
- 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:
-
oneStepAgileControllability
public OSTNU.OSTNUCheckStatus oneStepAgileControllability(AbstractCSTN.EdgesToCheck<OSTNUEdgePluggable> edgesToCheck, Instant timeoutInstant) Executes one step of the agile controllability check.
Before the first execution of this method, it is necessary to executeinitAndCheck()
.- Parameters:
edgesToCheck
- set of edges that have to be checked.timeoutInstant
- time instant limit allowed to the computation.- Returns:
- the update status (for convenience. It is not necessary because return the same parameter status).
-
reset
public void reset()Resets all internal structures- Overrides:
reset
in classAbstractCSTN<OSTNUEdgePluggable>
-
checkAndManageIfNewLabeledValueIsANegativeLoop
boolean checkAndManageIfNewLabeledValueIsANegativeLoop(int value, @Nonnull Label label, @Nonnull LabeledNode source, @Nonnull LabeledNode destination, @Nonnull OSTNUEdgePluggable newEdge) Checks if a new labeled value is negative and represents a negative cycle. In such a case, update the status adding the new scenario in the list of negative scenarios.- Parameters:
value
- valuelabel
- label of the valuesource
- source nodedestination
- destination nodenewEdge
- new edge- Returns:
- true if a negative loop has been found in the given scenario and that there is no alternative scenario to it (i.e., there are two scenario that present negative loop w.r.t. the value generated by a contingent time point, one using oracle, one not using oracle).
-
getLabel4ValueInvolvingContingent
@Nonnull Label getLabel4ValueInvolvingContingent(@Nonnull LabeledNode contingent, @Nonnull LabeledNode node, boolean straight) - Parameters:
contingent
- contingent nodenode
- other node for which it is necessary to determine the label for constraint involving contingent and node.straight
- true if the label is relative to value determined using oracle rule, false otherwise.- Returns:
- the label used by lower case/upper case/oracle rules to label values involving contingent node.
-
isAllMaxMinimalGraphConsistent
Determines the minimal distance between all pairs of vertexes of the given graph if the graph is consistent, i.e., it does not contain any negative cycles.- Parameters:
graph
- the graph. It will be modified- Returns:
- true if the input graph is consistent, i.e., it does not contain any negative cycle; false otherwise.
-
labeledCrossCaseRule
void labeledCrossCaseRule(@Nonnull LabeledNode nA, @Nonnull LabeledNode nC, @Nonnull LabeledNode nX, @Nonnull OSTNUEdgePluggable eAC, @Nonnull OSTNUEdgePluggable eCX, @Nonnull OSTNUEdgePluggable eAX) Labeled Cross Case RuleA ---(u,c,α)--→ C ---(v,D,β)--→ X adds A ---(u+v,D,αβ)--→ X if αβ∈P, C != D, and v ≤ 0.
Since it is assumed that L(C)=L(A)=α, there is only ONE lower-case labeled value u,c,α!- Parameters:
nA
- nodenC
- nodenX
- nodeeAC
- CANNOT BE NULLeCX
- CANNOT BE NULLeAX
- CANNOT BE NULL
-
labeledLetterRemovalRule
void labeledLetterRemovalRule(@Nonnull LabeledNode nX, @Nonnull LabeledNode nA, @Nonnull OSTNUEdgePluggable eXA) Labeled Letter RemovalX ---(v,ℵ,β)--→ A ---(x,c,α)--→ C adds X ---(m,ℵ',β)---→ A if C ∈ ℵ, m = max(v, −x), β entails α. ℵ'=ℵ'/C
- Parameters:
nX
- nodenA
- nodeeXA
- edge
-
labeledLowerCaseRule
void labeledLowerCaseRule(@Nonnull LabeledNode nA, @Nonnull LabeledNode nC, @Nonnull LabeledNode nX, @Nonnull OSTNUEdgePluggable eAC, @Nonnull OSTNUEdgePluggable eCX, @Nonnull OSTNUEdgePluggable eAX) Labeled Lower Case RuleX ←--(-u,◇,β)--- C ←--(x,c,α)----- A ---(v,◇,β')---→ --(-y,◇,-----→ adds X ←-----(x-u,◇,¬cαββ')------------ A if ¬cαββ'∈P, -u≤0, and (Oracle O_C does not exist or v-u≥y-x).
Since it is assumed that L(C)=L(A), there is only ONE lower-case labeled value u,c,α!
- Parameters:
nA
- nodenC
- nodenX
- nodeeAC
- CANNOT BE NULLeCX
- CANNOT BE NULLeAX
- CANNOT BE NULL
-
labeledOracleRule
void labeledOracleRule(@Nonnull LabeledNode nA, @Nonnull LabeledNode nC, @Nonnull LabeledNode nX, @Nonnull OSTNUEdgePluggable eAC, @Nonnull OSTNUEdgePluggable eCX, @Nonnull OSTNUEdgePluggable eAX) Oracle rule.X ---(v,◇,β)-→ C ---(-y,C,α)-→ A ←--(-u,◇,β')--| ←--(x,c,α)--- | (0) | ↓ O_C adds X ---(v-x,◇,αcβ)--------------→ A ←--(y-u,◇,αcβ')-----------------| | C | | | | | (-u,◇,αcββ') | | | | | ↓ | |-(0,◇,αcββ')→ O_C ←(x-u,◇,αcββ') when X is not contingent, αcββ' is consistent, and it is not subsumed by a negative scenario, and v-u < y-x
- Parameters:
nA
- nodenC
- nodenX
- nodeeAC
- CANNOT BE NULLeCX
- CANNOT BE NULLeAX
- CANNOT BE NULL
-
labeledPropagationRule
void labeledPropagationRule(@Nonnull LabeledNode nX, @Nonnull LabeledNode nY, @Nonnull LabeledNode nW, @Nonnull OSTNUEdgePluggable eXY, @Nonnull OSTNUEdgePluggable eYW, @Nonnull OSTNUEdgePluggable eXW) Applies 'labeled no case' or 'labeled upper case propagation' rules.
1) CASE labeled no case, labeled upper case propagation X ----(u,◇,α)---→ Y ----(v,ℵ,β)-----→ W adds X -----------(u+v,ℵ,αβ)------------→ W ℵ can be empty. αβ must be consistent and not in negative scenarios
- Parameters:
nX
- nodenY
- nodenW
- nodeeXY
- CANNOT BE NULLeYW
- CANNOT BE NULLeXW
- CANNOT BE NULL
-
labeledUpperCaseRule
void labeledUpperCaseRule(@Nonnull LabeledNode nX, @Nonnull LabeledNode nC, @Nonnull LabeledNode nA, @Nonnull OSTNUEdgePluggable eXC, @Nonnull OSTNUEdgePluggable eCA, @Nonnull OSTNUEdgePluggable eXA) Applies 'labeled upper case' rules.
2) labeled upper case A ←--(-y,C,𝛂)---- C ←-(v,◇,β)-------- X ---(x,C,𝛂)----→ --(-u,◇,β')-----→ adds A ←---(y+v,C,¬c𝛂ββ')----------------- X when ¬c𝛂ββ' is consistent and it is not subsumed by a negative scenario. Oracle for Y does not exist or v-u ≥ y-x.
- Parameters:
nX
- nodenC
- nodenA
- nodeeXC
- CANNOT BE NULLeCA
- CANNOT BE NULLeXA
- CANNOT BE NULL
-
makeAllMaxProjection
TNGraph<OSTNUEdgePluggable> makeAllMaxProjection() -
removeLabeledValuesBelongingToNegativeScenarios
void removeLabeledValuesBelongingToNegativeScenarios()Removes all labeled values belonging to negative scenarios.
-