Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Input to the service

Percy Mamedy edited this page Jun 7, 2016 · 1 revision

Creating the Problem object

The Problem object states the initial problem for which we need a decision for. See structure

$problem = App::make('TradeoffProblem', [
    'subject' => 'FooBar',
    'columns' => [...] //Array of ProblemColumn objects
    'options' => [...] //Array of ProblemOption objects
]);

or

$problem = make_tradeoff_problem([
    'subject' => 'FooBar',
    'columns' => [...] //Array of ProblemColumn objects
    'options' => [...] //Array of ProblemOption objects
]);

Creating the ProblemColumn object

A ProblemColumn is an objective or goal for which we have to take into account for making a decision. See structure

$data = [
    'key' => 'Somekey', //An identifier for the column
    'type' => 'numeric', //Column Type (numeric, datetime, categorical or text)
    'goal' => 'max', //Whether to maximize or minimize against this column
    'is_objective' => true, //Indicates whether the column is an objective for the decision problem
    'range' => ..., //A ProblemColumnCategoricalRange, ProblemColumnDateRange, or ProblemColumnValueRange object that indicates the range of valid values for a categorical, datetime, or numeric column, respectively.
    'preference' => [...], //For columns whose type is categorical, a preferred subset of the strings in the column's range; valid only for categorical columns.
    'significant_gain' => 0.2, //A significant gain for the column in the range of 0 to 1. Relevant only for columns whose is_objective field is true.
    'significant_loss' => 0.1, //A significant loss for the column in the range of 0 to 1. Relevant only for columns whose is_objective field is true.
    'insignificant_loss' => 0.1, //An insignificant loss for the column in the range of 0 to 1. Relevant only for columns whose is_objective field is true.
    'format' => 'number: 2', // For columns whose type is numeric or datetime, an optional pattern that indicates how the value is to be presented by the visualization. 
    'full_name' => 'FoobarColumn', //A descriptive name for the column.
    'description' => 'Foobar Description' // A long description for the column.
];

then

$problemColumn = App::make('TradeoffProblemColumn', $data);

or

$problemColumn = make_tradeoff_problem_column($data);

Creating the ProblemColumnCategoricalRange object

A ProblemColumnCategoricalRange defines a lists of values or categories for the ProblemColumn. See structure

$data = ['foo', 'bar'];

then

$problemColumnCategoricalRange = App::make('TradeoffProblemColumnCategoricalRange', $data);

or

$problemColumnCategoricalRange = make_tradeoff_problem_column_categorical_range($data);

then

$problemColumn->addRange($problemColumnCategoricalRange);

Creating the ProblemColumnDateRange object

A ProblemColumnDateRange object specifies the range of valid dates for the ProblemColumn. See structure

$data = [
  'low' => ... // The low end of the range as a Carbon Date Object,
  'high' => ... // The high end of the range as a Carbon Date Object
];

then

$problemColumnDateRange = App::make('TradeoffProblemColumnDateRange', $data);

or

$problemColumnDateRange = make_tradeoff_problem_column_date_range($data);

then

$problemColumn->addRange($problemColumnDateRange);

Creating the ProblemColumnValueRange object

The ProblemColumnValueRange object sets a low and high end numeric range values for the ProblemColumn. See structure

$data = [1, 10];

then

$problemColumnValueRange = App::make('TradeoffProblemColumnValueRange', $data);

or

$problemColumnValueRange = make_tradeoff_problem_column_value_range($data);

then

$problemColumn->addRange($problemColumnValueRange);

Creating the ProblemOption object

A ProblemOption is an object that represents one of the options from which we have to choose. See structure

$data = [
    'key' => 'SomeKey', //An identifier for the option.
    'values' => [...], //An array of key-value pairs that specifies a value for each column (objective) of the decision problem in the format "values": [ "price" => 100, "weight" => 20 ]
    'name' => 'SomeName', //The name of the option.
    'description_html' => '...' //A description of the option in HTML format.
    'app_data' => [...] //An of key-value pairs in which the application can pass application-specific information 
];

then

$problemOption = App::make('TradeoffProblemOption', $data);

or

$problemOption = make_tradeoff_problem_option($data);