PSG Matrix in MATLAB is a numerical matrix with text header for column names (variables of an optimization problems). Optionally includes columns: scenario benchmark, scenario probability, id. This object is commonly used for specifying functions data.
PSG Matrix consists of:
name |
name of matrix; |
vars |
tab separated or cell array of component names (names of variables of PSG problem); |
data |
values of data (real or integer); |
scenario_benchmark |
values of benchmark of scenarios (real or integer); |
scenario_probability |
values of probabilities of scenarios (positive real). |
Remarks
Name of matrix should not exceed 128 symbols, it is not case sensitive and includes only alphabetic characters, numbers, and underscore sign, “_”.
There are two ways for creation of PSG Matrix in MATLAB:
• | use tbpsg_matrix_pack for packing data to structure. |
PSG Matrix in MATLAB is a set of nested structures:
First level is a structure with three fields:
type |
string with type of PSG object: 'matrix', 'pmatrix', 'point', 'vector', 'parameter'; |
data |
structure with numeric and string values of matrix; |
string |
structure with names of MATLAB variables that corresponds to numeric and string values of matrix; |
Second level are two structures with the fields:
1. Data structure:
name |
string with name of matrix; |
vars |
string with tab separated component names (names of variables of PSG problem); |
data |
values of data (real or integer); |
bench |
values of benchmark of scenarios (real or integer); |
prob |
values of probabilities of scenarios (positive real). |
2. String structure:
name |
MATLAB variable for string with name of matrix; |
vars |
MATLAB variable for string with tab separated component names (names of variables of PSG problem); |
data |
MATLAB variable for values of data (real or integer); |
bench |
MATLAB variable for values of benchmark of scenarios (real or integer); |
prob |
MATLAB variable for values of probabilities of scenarios (positive real). |
Note. Create or modify described above structures is NOT recommended.
Here is the PSG Matrix for an example problem:
b1 |
b2 |
scenario_probability |
scenario_benchmark |
-1 |
0 |
0.1 |
0 |
0 |
0 |
0.9 |
0 |
Pack this matrix to the structure "toolboxstruc_arr":
vars = {'b1', 'b2'};
matrix = [-1 0; 0 0];
benchmark = [0 0];
probability = [0.1 0.9];
toolboxstruc_arr = tbpsg_matrix_pack('matrix_scenarios', matrix, vars, benchmark, probability);
Output:
>> toolboxstruc_arr
toolboxstruc_arr =
type: 'matrix'
data: [1x1 struct]
string: [1x1 struct]
>> toolboxstruc_arr.data
ans =
name: 'scenarios'
data: [2x2 double]
vars: 'b1 b2'
bench: [2x1 double]
prob: [2x1 double]
>> toolboxstruc_arr.data.data
ans =
-1 0
0 0
>> toolboxstruc_arr.string
ans =
name: 'scenarios'
data: 'matrix'
vars: 'vars'
bench: 'benchmark'
prob: 'probability'
PSG Matrix in Toolbox, PSG Matrix in General (Text) Format