PSG PMatrix in MATLAB is a PSG Matrix with numerical data stored in sparse format.

 

Description

Creation

Technical description

Example

 

Description

 

PSG PMatrix consists of:

 

name

name of sparse matrix;

vars

tab separated or cell array of component names (names of variables of PSG problem);

data

values of data (real or integer);

 

Remarks

Name of  sparse matrix should not exceed 128 symbols, it is not case sensitive and includes only alphabetic characters, numbers, and  underscore sign, “_”.

 

Creation

 

There are two ways for creation of PSG Parameter in MATLAB:

use PSG PMatrix in Toolbox GUI;
use tbpsg_pmatrix_pack for packing data to structure.

 

Technical description

 

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 pmatrix;

string

structure with names of MATLAB variables that corresponds to numeric and string values of pmatrix;

 

Second level are two structures with the fields:

 

1. Data structure:

name

string with name of pmatrix;

vars

string with tab separated component names (names of variables of PSG problem);

data

values of data (real or integer);

 

2. String structure:

name

MATLAB variable for string with name of pmatrix;

vars

MATLAB variable for string with tab separated component pnames (names of variables of PSG problem);

data

MATLAB variable for values of pmatrix;

 

Note. Create or modify described above structures is NOT recommended.

 

Example

 

Here is a PSG matrix in standard form:

x1

x2

x3

x4

11

22

0

0

0

33

44

0

0

0

0

55

66

0

77

0

0

88

0

99

In Sparse Matrix (PMatrix) format this matrix has the following structure:

x1

x2

x3

x4

1

1

11

 

1

2

22

 

2

2

33

 

2

3

44

 

3

4

55

 

4

1

66

 

4

3

77

 

5

2

88

 

5

4

99

 

Pack this pmatrix to the structure "toolboxstruc_arr":

vars = {'x1', 'x2', 'x3', 'x4'};

pmatrix=sparse([11 22 0 0; 0 33 44 0; 0 0 0 55; 66 0 77 0; 0 88 0 99]);

toolboxstruc_arr = tbpsg_pmatrix_pack('pmatrix_scenarios', pmatrix, vars);

 

Output:

>> toolboxstruc_arr

toolboxstruc_arr =

     type: 'pmatrix'

     data: [1x1 struct]

   string: [1x1 struct]

 

>> toolboxstruc_arr.data

ans =

   name: 'scenarios'

   data: [5x4 double]

   vars: 'x1        x2        x3        x4'

 

>> toolboxstruc_arr.data.data

ans =

  (1,1)       11

  (4,1)       66

  (1,2)       22

  (2,2)       33

  (5,2)       88

  (2,3)       44

  (4,3)       77

  (3,4)       55

  (5,4)       99

 

>> toolboxstruc_arr.string

ans =

   name: 'scenarios'

   data: 'pmatrix'

   vars: 'vars'

 

See also

PSG PMatrix in Toolbox, PSG Matrix in General (Text) Format