SetBuilderDefinition Structure

Note: This API is now obsolete.
Set builder containing set key and definition information.

Definition

Namespace: Orx.MathProg
Assembly: Orx.MathProg (in Orx.MathProg.dll) Version: 1.0.0
C#
public readonly struct SetBuilderDefinition
Inheritance
Object    ValueType    SetBuilderDefinition

Methods

DependsOn(Set) Adds a dependent set to the set definition.

Consider the following example.

C#
int numNodes = 4;
List<(int, int)> edges = new()
{
    (0, 1),
    (0, 2),
    (1, 2),
    (1, 3),
    (2, 3),
};
IEnumerable<int> getHeads(int i)
    => edges.Where(e => e.Item1 == i).Select(x => x.Item2);

Set i = Set("i").Represents("nodes").HasElementsUntil(numNodes);
Set j = Set("j").Represents("nodes having an arc from node i").DependsOn(i).HasElements(getHeads);

Here, set i has indices { 0, 1, 2, 3 }.

Set j, on the other hand, depends on set i. In other words, it will generate different elements for different values of i:

  • when i takes value 0; j has elements { 1, 2 },
  • when i takes value 1; j has elements { 2, 3 },
  • when i takes value 2; j has elements { 3 }, and
  • when i takes value 3; j is empty set.
DependsOn(Set, Set) Adds dependent sets to the set definition.

Consider the following example.

C#
int numNodes = 4;
List<(int, int)> edges = new()
{
    (0, 1),
    (0, 2),
    (1, 2),
    (1, 3),
    (2, 3),
};
IEnumerable<int> getHeads(int i)
    => edges.Where(e => e.Item1 == i).Select(x => x.Item2);

Set i = Set("i").Represents("nodes").HasElementsUntil(numNodes);
Set j = Set("j").Represents("nodes having an arc from node i").DependsOn(i).HasElements(getHeads);

Here, set i has indices { 0, 1, 2, 3 }.

Set j, on the other hand, depends on set i. In other words, it will generate different elements for different values of i:

  • when i takes value 0; j has elements { 1, 2 },
  • when i takes value 1; j has elements { 2, 3 },
  • when i takes value 2; j has elements { 3 }, and
  • when i takes value 3; j is empty set.
DependsOn(Set, Set, Set) Adds dependent sets to the set definition.

Consider the following example for two dependent set example.

C#
int numNodes = 4;
List<(int, int)> edges = new()
{
    (0, 1),
    (0, 2),
    (1, 2),
    (1, 3),
    (2, 3),
};
IEnumerable<int> getHeads(int i)
    => edges.Where(e => e.Item1 == i).Select(x => x.Item2);

Set i = Set("i").Represents("nodes").HasElementsUntil(numNodes);
Set j = Set("j").Represents("nodes having an arc from node i").DependsOn(i).HasElements(getHeads);

Here, set i has indices { 0, 1, 2, 3 }.

Set j, on the other hand, depends on set i. In other words, it will generate different elements for different values of i:

  • when i takes value 0; j has elements { 1, 2 },
  • when i takes value 1; j has elements { 2, 3 },
  • when i takes value 2; j has elements { 3 }, and
  • when i takes value 3; j is empty set.
DependsOn(Set, Set, Set, Set) Adds dependent sets to the set definition.

Consider the following example for two dependent set example.

C#
int numNodes = 4;
List<(int, int)> edges = new()
{
    (0, 1),
    (0, 2),
    (1, 2),
    (1, 3),
    (2, 3),
};
IEnumerable<int> getHeads(int i)
    => edges.Where(e => e.Item1 == i).Select(x => x.Item2);

Set i = Set("i").Represents("nodes").HasElementsUntil(numNodes);
Set j = Set("j").Represents("nodes having an arc from node i").DependsOn(i).HasElements(getHeads);

Here, set i has indices { 0, 1, 2, 3 }.

Set j, on the other hand, depends on set i. In other words, it will generate different elements for different values of i:

  • when i takes value 0; j has elements { 1, 2 },
  • when i takes value 1; j has elements { 2, 3 },
  • when i takes value 2; j has elements { 3 }, and
  • when i takes value 3; j is empty set.
Equals
(Inherited from ValueType)
GetHashCode
(Inherited from ValueType)
GetType
(Inherited from Object)
HasElements(FuncIEnumerableInt32, String) Finalizes the set builder and returns the resulting set.

The set generates elements by the function getIndices.

For instance, the following set:

C#
IEnumerable<int> GetHighPriorityIndices() => new int[] { 1, 4, 9 };
Set p = Set("p").Represents("prioritized projects").HasElements(GetHighPriorityIndices);
has elements { 1, 4, 9 }.
HasElements(IEnumerableInt32, String) Finalizes the set builder and returns the resulting set.

The set generates elements in [start, untilExclusive).

For instance, the following set:

C#
Set i = Set("i").Represents("resources").HasElementsIn(1, 4);
has elements { 1, 2, 3 }.
HasElementsIn Finalizes the set builder and returns the resulting set.

The set generates elements in [start, untilExclusive).

For instance, the following set:

C#
Set i = Set("i").Represents("resources").HasElementsIn(1, 4);
has elements { 1, 2, 3 }.
HasElementsUntil Finalizes the set builder and returns the resulting set.

The set generates elements in [0, untilExclusive).

For instance, the following set:

C#
int numNodes = 4;
Set i = Set("i").Represents("nodes").HasElementsUntil(numNodes);
has elements { 0, 1, 2, 3 }.
ToString
(Inherited from ValueType)

See Also