Class AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer>
Base class for layout operations.
Inheritance
Namespace: Edgar.GraphBasedGenerator.Common
Assembly: Edgar.dll
Syntax
public abstract class AbstractLayoutController<TLayout, TNode, TConfiguration, TShapeContainer> : Object, IChainBasedLayoutOperations<TLayout, TNode>, ILayoutOperations<TLayout, TNode>, IRandomInjectable where TLayout : ILayout<TNode, TConfiguration>, ISmartCloneable<TLayout> where TConfiguration : IConfiguration<TShapeContainer, Vector2Int, TNode>, ISmartCloneable<TConfiguration>
Type Parameters
Name | Description |
---|---|
TLayout | |
TNode | |
TConfiguration | |
TShapeContainer |
Remarks
It is useful when debugging algorithms based on probabilties.
Constructors
AbstractLayoutController(Int32, ILevelDescription<TNode>, IRoomShapesHandler<TLayout, TNode, TShapeContainer>, IRoomShapeGeometry<TConfiguration>)
Declaration
protected AbstractLayoutController(int averageSize, ILevelDescription<TNode> levelDescription, IRoomShapesHandler<TLayout, TNode, TShapeContainer> roomShapesHandler, IRoomShapeGeometry<TConfiguration> roomShapeGeometry)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | averageSize | |
ILevelDescription<TNode> | levelDescription | |
IRoomShapesHandler<TLayout, TNode, TShapeContainer> | roomShapesHandler | |
IRoomShapeGeometry<TConfiguration> | roomShapeGeometry |
Fields
AverageSize
Declaration
protected int AverageSize
Field Value
Type | Description |
---|---|
System.Int32 |
DifferenceFromAverageScale
Declaration
protected float DifferenceFromAverageScale
Field Value
Type | Description |
---|---|
System.Single |
LevelDescription
Declaration
protected readonly ILevelDescription<TNode> LevelDescription
Field Value
Type | Description |
---|---|
ILevelDescription<TNode> |
Random
Declaration
protected Random Random
Field Value
Type | Description |
---|---|
System.Random |
RoomShapeGeometry
Declaration
protected readonly IRoomShapeGeometry<TConfiguration> RoomShapeGeometry
Field Value
Type | Description |
---|---|
IRoomShapeGeometry<TConfiguration> |
RoomShapesHandler
Declaration
protected readonly IRoomShapesHandler<TLayout, TNode, TShapeContainer> RoomShapesHandler
Field Value
Type | Description |
---|---|
IRoomShapesHandler<TLayout, TNode, TShapeContainer> |
ShapePerturbChance
Declaration
protected float ShapePerturbChance
Field Value
Type | Description |
---|---|
System.Single |
StageOneGraph
Declaration
protected readonly IGraph<TNode> StageOneGraph
Field Value
Type | Description |
---|---|
IGraph<TNode> |
Methods
AddChain(TLayout, IList<TNode>, Boolean, out Int32)
Adds a given chain by greedily adding nodes one by one.
Declaration
public virtual void AddChain(TLayout layout, IList<TNode> chain, bool updateLayout, out int iterationsCount)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | |
System.Collections.Generic.IList<TNode> | chain | |
System.Boolean | updateLayout | Whether energies should be updated. |
System.Int32 | iterationsCount |
AddNodeGreedily(TLayout, TNode, out Int32)
Adds a given node greedily to a given layout.
Declaration
public abstract void AddNodeGreedily(TLayout layout, TNode node, out int iterationsCount)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | |
TNode | node | |
System.Int32 | iterationsCount |
AreDifferentEnough(TLayout, TLayout)
Checks if given layouts are different enough.
Declaration
public virtual bool AreDifferentEnough(TLayout layout1, TLayout layout2)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout1 | |
TLayout | layout2 |
Returns
Type | Description |
---|---|
System.Boolean |
AreDifferentEnough(TLayout, TLayout, IList<TNode>)
Checks if two layouts are different enough by comparing positions of corresponding nodes.
Declaration
public virtual bool AreDifferentEnough(TLayout layout1, TLayout layout2, IList<TNode> chain)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout1 | |
TLayout | layout2 | |
System.Collections.Generic.IList<TNode> | chain |
Returns
Type | Description |
---|---|
System.Boolean |
GetEnergy(TLayout)
Gets the energy of a given layout.
Declaration
public abstract float GetEnergy(TLayout layout)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout |
Returns
Type | Description |
---|---|
System.Single |
InjectRandomGenerator(Random)
Injects an instance of a random numbers generator.
Declaration
public virtual void InjectRandomGenerator(Random random)
Parameters
Type | Name | Description |
---|---|---|
System.Random | random |
IsLayoutValid(TLayout)
Checks if all configurations are valid.
Declaration
public abstract bool IsLayoutValid(TLayout layout)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Layout without some configurations may be valid, too.
IsLayoutValid(TLayout, IList<TNode>)
Checks if a given layout has all configurations from a given chain and that all configurations are valid.
Declaration
public abstract bool IsLayoutValid(TLayout layout, IList<TNode> chain)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | |
System.Collections.Generic.IList<TNode> | chain |
Returns
Type | Description |
---|---|
System.Boolean |
PerturbLayout(TLayout, IList<TNode>, Boolean)
Perturbs a given layout by first choosing whether to perturb a shape or a positions and than calling corresponding methods.
Declaration
public virtual void PerturbLayout(TLayout layout, IList<TNode> chain, bool updateLayout)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | |
System.Collections.Generic.IList<TNode> | chain | Chain of nodes to choose from. |
System.Boolean | updateLayout | Whether energies should be updated. |
PerturbPosition(TLayout, TNode, Boolean)
Pertubs a position of a given node by getting a random point from a maximum intersection of configuration space of already laid out neighbours. TODO: is "laid out" ok?
Declaration
public virtual void PerturbPosition(TLayout layout, TNode node, bool updateLayout)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | |
TNode | node | Node to be perturbed. |
System.Boolean | updateLayout | Whether energies should be updated. |
PerturbPosition(TLayout, IList<TNode>, Boolean)
Perturbs position of a random node from a given chain.
Declaration
public virtual void PerturbPosition(TLayout layout, IList<TNode> chain, bool updateLayout)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | |
System.Collections.Generic.IList<TNode> | chain | Chain of nodes to choose from. |
System.Boolean | updateLayout | Whether energies should be updated. |
PerturbShape(TLayout, TNode, Boolean)
Perturbs a node by getting random shapes from configurations spaces until a different shape is found.
Declaration
public virtual void PerturbShape(TLayout layout, TNode node, bool updateLayout)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | |
TNode | node | Node to be perturbed. |
System.Boolean | updateLayout | Whether energies should be updated. |
PerturbShape(TLayout, IList<TNode>, Boolean)
Perturbs shape of a random node from a given chain.
Declaration
public virtual void PerturbShape(TLayout layout, IList<TNode> chain, bool updateLayout)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | |
System.Collections.Generic.IList<TNode> | chain | Chain of nodes to choose from. |
System.Boolean | updateLayout | Whether energies should be updated. |
TryCompleteChain(TLayout, IList<TNode>)
Tries to complete a given chain. This operation may fail, in which case false is returned and the layout is not modified.
Declaration
public virtual bool TryCompleteChain(TLayout layout, IList<TNode> chain)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | |
System.Collections.Generic.IList<TNode> | chain |
Returns
Type | Description |
---|---|
System.Boolean | Whether a given chain was completed successfully |
Remarks
Do nothing. Implementers may override.
UpdateLayout(TLayout)
Updates energies of a given layout.
Declaration
public abstract void UpdateLayout(TLayout layout)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout |
UpdateLayout(TLayout, TNode, TConfiguration)
Updates energies after perturbing a given node.
Declaration
protected abstract void UpdateLayout(TLayout layout, TNode perturbedNode, TConfiguration configuration)
Parameters
Type | Name | Description |
---|---|---|
TLayout | layout | Original layout. |
TNode | perturbedNode | Node that was perturbed. |
TConfiguration | configuration | New configuration of the perturbed node. |
Remarks
This method is responsible for modifying the layout by setting the configuration to the perturbed node.