Class PSTN
Beta Version From 2024-06-13, it is not clear whether this class will be developed to become a full-fledged model. Therefore, to this day, I do not extend the TNGraphML* classes to represent such a kind of network.
Inside this class, the log-normal parameters associated with each contingent link are represented as a hash map and are not saved to file.
The only experiment we are planning to do is to load STNU instances, transform them into PSTN, changing all contingent links into probabilistic contingent links, and find an STNU approximation that guarantees the dynamic controllability of the original PSTN with the maximum probability.
- Version:
- $Rev: 878 $
- Author:
- Roberto Posenato
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Extends STNCheckStatus to represent the result of the approximating STNU. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Suffix for file name(package private) double
Factor used to determine the bounds of a contingent link from location and the standard deviation of the log-normal distribution inbuildApproxSTNU()
(package private) static final String
Version of the classstatic final String
The name for the initial node. -
Constructor Summary
ConstructorsConstructorDescriptionPSTN()
Default constructor.Given a PSTN graph, it uses it as a network (does not make a copy).PSTN
(TNGraph<STNUEdge> graph, int expanderFactor, double sigmaFactor, double rangeFactor, OptimizationEngine optimizationEngine) PSTN
(TNGraph<STNUEdge> graph, int expanderFactor, double sigmaFactor, OptimizationEngine optimizationEngine) Given an STNU graph, it uses it as a base for it (does not make a copy). -
Method Summary
Modifier and TypeMethodDescriptionDetermines(Su, F)
, where Su = (T, C, L) is a dynamically controllable STNU where L = {(Ai, xi, yi, Ci) | i ∈ {1, ..., k}} and F is the value of the objective function (i.e., the joint probability mass of the probabilistic durations in this PSTN network captured by the contingent links in L).final it.unimi.dsi.fastutil.objects.Object2ObjectMap
<LabeledNode, LabeledNode> int
getG()
int
final it.unimi.dsi.fastutil.objects.Object2ObjectMap
<LabeledNode, STNUEdge> Returns a map containing the lower-case edges associated with the contingent link of the network if the network was initialized (initAndCheck()
executed successfully); null otherwise.int
int
it.unimi.dsi.fastutil.objects.Object2ObjectMap
<LabeledNode, STNUEdge> Returns a map containing the upper-case edges associated with the contingent link of the network if the network was initialized (initAndCheck()
executed successfully); null otherwise.final String
static String
final void
Makes the PSTN check and initialization.boolean
isSave()
boolean
final void
reset()
Resets all internal structures.final void
Stores the graph after a check of the file.final void
setfOutput
(File fileOutput) final void
Considers the given graph as the graph to check (the graph will be modified).void
setOptimizationEngine
(OptimizationEngine optimizationEngine) final void
setSave
(boolean s) void
updateContingentBounds
(STNU approximatedSTNU) A PSTN maintains bounds of a contingent link as a lower / upper case-edge value.
-
Field Details
-
FILE_NAME_SUFFIX
Suffix for file name- See Also:
-
ZERO_NODE_NAME
The name for the initial node.- See Also:
-
VERSIONandDATE
Version of the class- See Also:
-
rangeFactor
double rangeFactorFactor used to determine the bounds of a contingent link from location and the standard deviation of the log-normal distribution inbuildApproxSTNU()
-
-
Constructor Details
-
PSTN
public PSTN(TNGraph<STNUEdge> graph, int expanderFactor, double sigmaFactor, double rangeFactor, OptimizationEngine optimizationEngine) - Parameters:
graph
- TNGraph to checkexpanderFactor
- factor to amplify each edge valuesigmaFactor
- factor to determine σ.rangeFactor
- rangeFactor to use for determining the first contingent ranges in the approximating STNU for the checkoptimizationEngine
- Optimization engine for buildApproxSTNU will be used. It can be null.
-
PSTN
public PSTN(TNGraph<STNUEdge> graph, int expanderFactor, double sigmaFactor, OptimizationEngine optimizationEngine) Given an STNU graph, it uses it as a base for it (does not make a copy).For each contingent link, it multiplies each edge value by
expanderFactor
to guarantee that the log-normal distribution built for each contingent link allows the determination of integer values.For each contingent link, it associates with its contingent node a pair
(μ, σ)
to represent the log-normal distribution associated with the contingent link.μ
is the log-normal location, andσ
is the standard deviation. They are determined as follows.Let
x, y
be the (updated) bounds of a contingent link. LetM = (x+y)/2, S= (y-x)/2 * #sigmaFactor
. Then,μ = ln(M^2/(sqrt(M^2+S^2))
andσ = ln(1+ S^2/M^2)
.This method executes
initAndCheck()
on the input graph.- Parameters:
graph
- TNGraph to checkexpanderFactor
- factor to amplify each edge valuesigmaFactor
- factor to determine σ.optimizationEngine
- Optimization engine for buildApproxSTNU will be used. It can be null.- Throws:
IllegalArgumentException
- if any error occurs during initialinitAndCheck()
.
-
PSTN
Given a PSTN graph, it uses it as a network (does not make a copy). The contingent nodes must have a significantLabeledNode.getLogNormalDistribution()
.- Parameters:
graph
- PSTN in TNGraph format
-
PSTN
PSTN()Default constructor.
-
-
Method Details
-
getVersionAndDate
- Returns:
- the version
-
buildApproxSTNU
Determines(Su, F)
, where Su = (T, C, L) is a dynamically controllable STNU where L = {(Ai, xi, yi, Ci) | i ∈ {1, ..., k}} and F is the value of the objective function (i.e., the joint probability mass of the probabilistic durations in this PSTN network captured by the contingent links in L).The STNU has the same time-points and ordinary constraints as the PSTN, together with contingent links over the same activation and contingent time-points. If unable to find such an STNU or the STNU contains an SRN made by only ordinary edges, it returns a null approximating STNU.
- Returns:
- The result (Su, F) is stored in
PSTN.PSTNCheckStatus.approximatingSTNU
andPSTN.PSTNCheckStatus.probabilityMass
. If it is not possible to find an approximation because the optimization fails,PSTN.PSTNCheckStatus.exitFlag
assumes negative values (seeOptimizationEngine.OptimizationResult
), approximatingSTNU = null and probabilityMass = -1.
If it is not possible because the semi-reducible cycle is composed by only ordinary edges, thenPSTN.PSTNCheckStatus.exitFlag
is -10, approximatingSTNU = null and probabilityMass = -1.
If the approximating STNU was found without resolving any minimization problem,PSTN.PSTNCheckStatus.exitFlag
is 10.this.
g
is not modified. - Throws:
IllegalArgumentException
- ifg
is null org
does not contain contingent links.
-
getActivationNodeMap
@Nullable public final it.unimi.dsi.fastutil.objects.Object2ObjectMap<LabeledNode,LabeledNode> getActivationNodeMap()- Returns:
- the activationNode map if the network has been
initAndCheck()
, null otherwise.The map is (contingentNode, activationNode).
-
getAvgContingentRangeWidth
public int getAvgContingentRangeWidth()- Returns:
- the avgContingentRangeWidth
-
getG
- Returns:
- the g
-
getLowerCaseEdgesMap
@Nullable public final it.unimi.dsi.fastutil.objects.Object2ObjectMap<LabeledNode,STNUEdge> getLowerCaseEdgesMap()Returns a map containing the lower-case edges associated with the contingent link of the network if the network was initialized (initAndCheck()
executed successfully); null otherwise. In particular, if the network contains the contingent link(A, 1, 3, C)
, the returned map contains the pairC --> (A, c(1), C)
.- Returns:
- the lowerContingentEdge map
-
getHorizon
public int getHorizon()- Returns:
- the horizon of the network
-
getMaxWeight
public int getMaxWeight()- Returns:
- the absolute max weight of the network
-
getOptimizationEngine
- Returns:
- the MATLAB Engine used by this class.
-
setOptimizationEngine
- Parameters:
optimizationEngine
- the new MATLAB Engine to use.
-
getUpperCaseEdgesMap
@Nullable public it.unimi.dsi.fastutil.objects.Object2ObjectMap<LabeledNode,STNUEdge> getUpperCaseEdgesMap()Returns a map containing the upper-case edges associated with the contingent link of the network if the network was initialized (initAndCheck()
executed successfully); null otherwise. In particular, if the network contains the contingent link(A, 1, 3, C)
, the returned map containsC --> (C, C:-3, A)
.- Returns:
- the upper-case constraints map
-
getTimeOut
public int getTimeOut()- Returns:
- the time-out in seconds for the DC checking method.
-
getVersionAndCopyright
- Returns:
- version and copyright string
-
initAndCheck
Makes the PSTN check and initialization. The PSTN instance is represented by graph g. If some constraints of the network do not observe well-defined properties AND they can be adjusted, then the method fixes them and logs such fixes in the log system at the WARNING level. If the method cannot fix such not-well-defined constraints, it raises aWellDefinitionException
.- Throws:
WellDefinitionException
- if any error about the format of the network occurs
-
getfInput
- Returns:
- the fInput
-
getfOutput
- Returns:
- the fOutput
-
setfOutput
- Parameters:
fileOutput
- the file where to save the result.
-
isSave
public boolean isSave()- Returns:
- the saved
-
saveGraphToFile
public final void saveGraphToFile()Stores the graph after a check of the file. -
setSave
public final void setSave(boolean s) - Parameters:
s
- the save to set
-
isVersionReq
public boolean isVersionReq()- Returns:
- the versionReq
-
reset
public final void reset()Resets all internal structures. -
setG
Considers the given graph as the graph to check (the graph will be modified). Clear all internal parameters.- Parameters:
graph
- set internal TNGraph to g. It cannot be null.
-
updateContingentBounds
A PSTN maintains bounds of a contingent link as a lower / upper case-edge value. This is because, even though contingent link durations are described as distribution probability functions, the STRONG/DYNAMIC controllability of a PSTN is realized by approximating the network as an STNU.buildApproxSTNU()
allows the determination of a Dynamic Controllable approximating STNU that maximizes the probability mass for each contingent link. Such a method returns a DC STNU (if it exists) and doesn't touch the current network. This method saves the contingent bounds determined in the approximating STNU in the current network.- Parameters:
approximatedSTNU
- the approximating STNU. It has to have the same contingent links (name) and the same contingent node names to copy the bounds successfully.
-