Parameters represent input data for a model. Parameters are most useful when they are associated with Sets. Associating Sets with Parameters allows you define tables (or if you like: vectors  and matrices) of data: these are called "indexed parameters". When you use indexed parameters, data can change without having to update the model. A simple example is as follows:

        Set colors = new Set(Domain.Any, "colors");
        Parameter codes = new Parameter(Domain.IntegerRange(0, 2), "codes", colors);
        Tuple<string, int>[] codeData = { Tuple.Create("red", 0), Tuple.Create("green", 1),Tuple.Create("blue", 2) };
        codes.SetBinding(codeData, "Item2", "Item1");

We create a set, pass the set to the Parameter constructor to create an indexed decision with 0-1 entries. The values of a parameter are established through data binding using the SetBinding method shown above. Prior to Solver Foundation 3.0 it was necessary to specify parameter values for all the possible elements of each set used in the parameter. Let’s extend our example to define another Parameter using the same Set.

        Parameter tasteful = new Parameter(Domain.IntegerRange(0, 1), "tasteful", colors);
        Tuple<string, int>[] tasteData = { Tuple.Create("red", 1), Tuple.Create("blue", 1) };
        tasteful.SetBinding(codeData, "Item2", "Item1"); // error when we call Solve


No value was given for "green", so an error will occur when  we try to solve a model involving the parameter.

Solver Foundation 3.0 introduced the concept of sparse parameters. This simply means that parameters can be given default values. The parameter takes on the default value for any index combinations not specified in the SetBinding statement. If we modify the previous example the value tasteful[“green”] will be 0.

        tasteful.SetBinding(codeData, "Item2", 0, "Item1"); // default value 0


The documentation for the new SetBinding overload is located here. Unfortunately the Excel add-in does not take advantage of this new functionality. We hope to address this in a future release.