Method execution
Preparing method
Each decision-making method requires a specific configuration setup and a distinct set of parameters.
In the toolkit, these configurations are encapsulated in dedicated Options classes — one for each method.
All options classes implement the common IMcdaOptions
interface, which unifies shared settings such as the choice of normalization method
var options = new Promethee2Options()
{
NormalizationMethod = NormalizationMethod.MinMax,
PreferenceFunction = PreferenceFunction.Unnamed;
}
If a required property is not explicitly set in the options object, the toolkit will fall back to a method-specific default value. This behavior does not throw an exception, but it may lead to unintended behavior or unexpected results, especially if the default configuration does not match the intended use case.
To instantiate a specific multi-criteria decision-making (MCDM) method, use the MethodFactory
class.
The method instance after initialization will be immutable; however, the data passed into the method can be changed in each execution
Example of Promethee2 initialization:
var method = MethodFactory.CreatePromethee2(
new Promethee2Options()
{
NormalizationMethod = NormalizationMethod.MinMax,
PreferenceFunction = PreferenceFunction.Ushape;
})
Run method
The Run method is the main entry point for executing an MCDA algorithm. It takes a complete set of input data built using the DefaultDataProviderBuilder — and returns the result of the analysis - ranking for each alternative.
var result = method.Run(data);
The result of the calculation is returned as an object of type Result<T>
, provided by the LightResults library.
This structure not only contains the output data Value, but also encapsulates information about whether the operation failed or succeed.
Before accessing the Value property of the result object, it is essential to verify that the operation completed successfully.
Attempting to access the value without this check may throw InvalidOperationException
if(result.IsFailed)
{
return "error"
}
Ranking<T> ranking = result.Value;
Further details about Ranking<T>
can be found on the following pages.