Invert af multidimensional matrix

Problems with syntax of GAMS
Post Reply
jonathanl91
User
User
Posts: 6
Joined: 3 years ago

Invert af multidimensional matrix

Post by jonathanl91 »

Consider the following matrix for 2000 and 2001, respectively:

Code: Select all

Set i /i1*i2 /
    t /2000,2001/;

Alias (i,j);

parameters a(t,i,j) /
2000. i1. i1 2
2000. i1. i2 0
2000. i2. i1 0.272727
2000. i2. i2 2
2001. i1. i1 2
2001. i1. i2 0
2001. i2. i1 0.5
2001. i2. i2 2/;
Firstly, I want to invert the 2000 matrix, and thereafter the 2001 matrix.
I know I can use the following code to invert a 2-dimensional matrix:

Code: Select all

Parameter inva(i,j) 'inverse of a';

execute_unload 'a.gdx', i, a;
execute '=invert.exe a.gdx i a b.gdx inva';
execute_load 'b.gdx', inva;
But how do I do when I have a multidimensional matrix. I have tried with a loop - something like this:

Code: Select all

Parameter inva(t,i,j) 'inverse of a';

loop(t,
    execute_unload 'a.gdx', i, a;
    execute '=invert.exe a.gdx i a b.gdx inva';
    execute_load 'b.gdx', inva;
);
But that does not work. Can anyone help me?
Post Reply