Vertex Connection Strategies

Strategies when changing connection between vertices.

Imported to namespace by

using NaiveNASlib.Advanced
NaiveNASlib.RemoveStrategyType
RemoveStrategy
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.

source
NaiveNASlib.IncreaseSmallerType
IncreaseSmaller <: 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.

source
NaiveNASlib.DecreaseBiggerType
DecreaseBigger <: 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.

source
NaiveNASlib.PostAlignType
PostAlign <: 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.

source
NaiveNASlib.ChangeNinOfOutputsType
ChangeNinOfOutputs <: AbstractAlignSizeStrategy
ChangeNinOfOutputs(Δoutsize)

Just sets nin of each output to the provided utility. Sometimes you just know the answer...

source
NaiveNASlib.FailAlignSizeNoOpType
FailAlignSizeNoOp <: 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.

source
NaiveNASlib.FailAlignSizeWarnType
FailAlignSizeWarn <: AbstractAlignSizeStrategy
FailAlignSizeWarn()
FailAlignSizeWarn(;andthen, msgfun)

Logs warning and then proceeds with the next action.

source
NaiveNASlib.CheckAlignedType
CheckAligned <: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).

source
NaiveNASlib.CheckNoSizeCycleType
CheckNoSizeCycle <: 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.

source
NaiveNASlib.CheckCreateEdgeNoSizeCycleType
CheckCreateEdgeNoSizeCycle <: 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).

source