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.

Basic Module Graph Example

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...

// Create the modules RandomIntegerGenerator randomIntegerGenerator = new RandomIntegerGenerator(); IntegerDivider integerDivider = new IntegerDivider(); DoubleDivider doubleDivider = new DoubleDivider(); // Add the modules to the module graph ModuleGraph moduleGraph = new ModuleGraph(); moduleGraph.AddModule(randomIntegerGenerator); moduleGraph.AddModule(integerDivider); moduleGraph.AddModule(doubleDivider); // Create the slot links 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...

// Create the module graph processor and process the graph ModuleGraphProcessor processor = new ModuleGraphProcessor(); processor.Process(moduleGraph, false); // Output the results 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...