Vertex Connection Strategies
Strategies when changing connection between vertices.
Imported to namespace by
using NaiveNASlib.Advanced
NaiveNASlib.RemoveStrategy
— TypeRemoveStrategy
RemoveStrategy()
RemoveStrategy(rs::AbstractConnectStrategy)
RemoveStrategy(as::AbstractAlignSizeStrategy)
RemoveStrategy(rs::AbstractConnectStrategy, as::AbstractAlignSizeStrategy)
Strategy for removal of a vertex.
Consists of an AbstractConnectStrategy
for how to treat inputs and outputs of the removed vertex and an AbstractAlignSizeStrategy
for how to align sizes of inputs and outputs.
NaiveNASlib.IncreaseSmaller
— TypeIncreaseSmaller <: AbstractAlignSizeStrategy
IncreaseSmaller()
IncreaseSmaller(;mapstrat, fallback)
Try to align size by increasing in the direction (in/out) which has the smaller size. Fallback to another strategy (default DecreaseBigger
) if size change is not possible.
mapstrat
can be used to wrap the AbstractΔSizeStrategy
in a DecoratingJuMPΔSizeStrategy
. Main intended usecase is WithUtilityFun
. Note one might want to supply the same mapstrat
to any fallback strategies.
NaiveNASlib.DecreaseBigger
— TypeDecreaseBigger <: AbstractAlignSizeStrategy
DecreaseBigger()
DecreaseBigger(;fallback, mapstrat)
Try to align size by decreasing in the direction (in/out) which has the bigger size. Fallback to another strategy (default AlignSizeBoth
) if size change is not possible.
mapstrat
can be used to wrap the AbstractΔSizeStrategy
in a DecoratingJuMPΔSizeStrategy
. Main intended usecase is WithUtilityFun
. Note one might want to supply the same mapstrat
to any fallback strategies.
NaiveNASlib.AlignSizeBoth
— TypeAlignSizeBoth <: AbstractAlignSizeStrategy
AlignSizeBoth()
AlignSizeBoth(;fallback, mapstrat)
Align sizes by changing both input and output. Fallback to another strategy (default FailAlignSizeWarn
) if size change is not possible.
mapstrat
can be used to wrap the AbstractΔSizeStrategy
in a DecoratingJuMPΔSizeStrategy
. Main intended usecase is WithUtilityFun
. Note one might want to supply the same mapstrat
to any fallback strategies.
NaiveNASlib.PostAlign
— TypePostAlign <: AbstractAlignSizeStrategy
PostAlign()
PostAlign(s::AbstractAlignSizeStrategy)
PostAlign(s::AbstractAlignSizeStrategy, fallback)
Align sizes using a AbstractΔSizeStrategy
.
This is a post-align strategy, i.e it will be applied after a structural change has been made.
NaiveNASlib.ChangeNinOfOutputs
— TypeChangeNinOfOutputs <: AbstractAlignSizeStrategy
ChangeNinOfOutputs(Δoutsize)
Just sets nin
of each output to the provided utility. Sometimes you just know the answer...
NaiveNASlib.FailAlignSizeNoOp
— TypeFailAlignSizeNoOp <: AbstractAlignSizeStrategy
FailAlignSizeNoOp()
Don't do any size change and return failure status.
Note that this means that graphs will most likely be left corrupted state if used as a fallback.
NaiveNASlib.FailAlignSizeError
— TypeFailAlignSizeError <: AbstractAlignSizeStrategy
FailAlignSizeError()
Throws SizeAlignFailError
.
NaiveNASlib.FailAlignSizeWarn
— TypeFailAlignSizeWarn <: AbstractAlignSizeStrategy
FailAlignSizeWarn()
FailAlignSizeWarn(;andthen, msgfun)
Logs warning and then proceeds with the next action.
NaiveNASlib.NoSizeChange
— TypeNoSizeChange <: AbstractAlignSizeStrategy
NoSizeChange()
Don't do any size change.
NaiveNASlib.CheckAligned
— TypeCheckAligned <:AbstractAlignSizeStrategy
CheckAligned()
CheckAligned(ifnot)
Check if sizes are already aligned before making a change and return "go ahead" (true
) if this is the case. If not, proceed to execute another strategy (default CheckNoSizeCycle
).
NaiveNASlib.CheckNoSizeCycle
— TypeCheckNoSizeCycle <: AbstractAlignSizeStrategy
CheckNoSizeCycle()
CheckNoSizeCycle(;ifok, ifnok)
Check if a size change in one direction causes a change in the other direction and execute strategy ifnok
(default FailAlignSizeWarn
) if this is the case. Motivation is that removing will result in the computation graph being in an invalid state as one of the vertices must fulfill the impossible criterion nout(v)
==
nout(v)
+ a
where a > 0
.
If no such cycle is detected, then proceed to execute strategy ifok
(default IncreaseSmaller
).
Will execute strategy ifok
if vertex shall not to be removed.
NaiveNASlib.CheckCreateEdgeNoSizeCycle
— TypeCheckCreateEdgeNoSizeCycle <: AbstractAlignSizeStrategy
CheckCreateEdgeNoSizeCycle()
CheckCreateEdgeNoSizeCycle(;ifok, ifnok)
Check if adding an edge creates the same type of size cycle that CheckNoSizeCycle
checks for and execute ifnok
(default FailAlignSizeWarn
) if this is the case. Motivation is that removing will result in the computation graph being in an invalid state as one of the vertices must fulfill the impossible criterion nout(v)
==
nout(v)
+ a
where a > 0
.
If no such cycle is detected, then proceed to execute strategy ifok
(default IncreaseSmaller
).
Will check both at prealignsizes
(i.e before edge is added) and at postalignsizes
(i.e after edge is added).