Basic Workflow
The diagram below shows a representation of the basic module graph created at the start of the SimpleML.Samples.Program class. The 'Random Integer Generator' module creates two random integers (a larger and a smaller one), before passing these to two separate modules, both of which divide one integer by the other. The 'Double Divider' module returns the result of this division as a double, whilst the 'IntegerDivider' module returns the result as an integer quotient and remainder.
Although the functionality of this workflow is trivial, it highlights two key features of the MMF framework, namely..
- Modules can have multiple OutputSlots, and hence output multiple data values
- A single OutputSlot can be linked to multiple InputSlots
The modules, module graph, and slots links are created with the following code...
RandomIntegerGenerator randomIntegerGenerator = new RandomIntegerGenerator();
IntegerDivider integerDivider = new IntegerDivider();
DoubleDivider doubleDivider = new DoubleDivider();
ModuleGraph moduleGraph = new ModuleGraph();
moduleGraph.AddModule(randomIntegerGenerator);
moduleGraph.AddModule(integerDivider);
moduleGraph.AddModule(doubleDivider);
moduleGraph.CreateSlotLink(randomIntegerGenerator.GetOutputSlot("LargerInteger"), integerDivider.GetInputSlot("Dividend"));
moduleGraph.CreateSlotLink(randomIntegerGenerator.GetOutputSlot("SmallerInteger"), integerDivider.GetInputSlot("Divisor"));
moduleGraph.CreateSlotLink(randomIntegerGenerator.GetOutputSlot("LargerInteger"), doubleDivider.GetInputSlot("Dividend"));
moduleGraph.CreateSlotLink(randomIntegerGenerator.GetOutputSlot("SmallerInteger"), doubleDivider.GetInputSlot("Divisor"));
The workflow defined in the module graph is then executed by passing the module graph to the Process() method of the ModuleGraphProcessor class...
ModuleGraphProcessor processor = new ModuleGraphProcessor();
processor.Process(moduleGraph, false);
Console.WriteLine("LargerInteger: " + randomIntegerGenerator.GetOutputSlot("LargerInteger").DataValue);
Console.WriteLine("SmallerInteger: " + randomIntegerGenerator.GetOutputSlot("SmallerInteger").DataValue);
Console.WriteLine("Quotient: " + integerDivider.GetOutputSlot("Quotient").DataValue);
Console.WriteLine("Remainder: " + integerDivider.GetOutputSlot("Remainder").DataValue);
Console.WriteLine("Double Result: " + doubleDivider.GetOutputSlot("Result").DataValue);
The section of the Program class described above will create output similar to the following....
LargerInteger: 46
SmallerInteger: 4
Quotient: 11
Remainder: 2
Double Result: 11.5
Continue to Linear Regression Examples...