MathProgExtensionsHasElements(SetBuilderDependsDimension1, FuncInt32, IEnumerableInt32, String) Method

Finalizes the set builder and returns the resulting set.

The set generates elements in [0, getIndicesByDependsSet(i)); where i is the value of the dependent set.

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.

Definition

Namespace: Orx.MathProg
Assembly: Orx.MathProg (in Orx.MathProg.dll) Version: 1.0.0
C#
public static Set HasElements(
	this SetBuilderDepends<Dimension1> state,
	Func<int, IEnumerable<int>> getIndicesByDependsSet,
	string expression = ""
)

Parameters

state  SetBuilderDependsDimension1
Current state of the set builder.
getIndicesByDependsSet  FuncInt32, IEnumerableInt32
Function of the dependent set that returns the elements of this set.
expression  String  (Optional)
Element generator expression.

Return Value

Set

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type SetBuilderDependsDimension1. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also