help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## Re: [Help-glpk] How to express a parameter matrix as a data block in Mat

 From: Thiago Neves Subject: Re: [Help-glpk] How to express a parameter matrix as a data block in MathProg? Date: Tue, 2 Apr 2019 08:27:26 -0300

Correction: the documentation explains about slices on page 48, not 58.

Att,

Thiago H. Neves
(31) 98608-0666

Em ter, 2 de abr de 2019 às 08:24, Thiago Neves <address@hidden> escreveu:
Hi, Yuri!

You can define a data block like this:

data;

param F :=
[0,0,1] := 1
[0,1,0] := 2
[1,0,0] := 3
;

end;

If F is a sparse parameter, I suggest you to define it with defaults, so you don't have to put all the data.

Example:

param M, default 2;
param F{0..M, 0..M, 0..M}, default 0;

var x >=0;

minimize cost: sum{m1 in 1..M, m2 in 1..M, m3 in 1..M} x*F[m1, m2, m3];

About your comment on gmpl documentation:
"MathProg documentation http://gusek.sourceforge.net/gmpl.pdf doesn't
explain how to do this. It talks mostly about how to define sets, and
seems to focus on 2-dimensional data."

Actually, it explains about slices (the lines I used on F data block), page 58, and about how to define parameters with slices, page 50.

Att,

Thiago H. Neves

Em ter, 2 de abr de 2019 às 04:03, Yuri <address@hidden> escreveu:
I need to have a large tabulated parameter matrix, like this:

param m=7;
param F{1..m, 1..m, 1..m};   # tabulated function
I would like to define these numeric values in a data block (data; ...;
end;) in a separate file.

MathProg documentation http://gusek.sourceforge.net/gmpl.pdf doesn't
explain how to do this. It talks mostly about how to define sets, and
seems to focus on 2-dimensional data.

How to define values of F[i1,i2,i3]?

My simple attempt:

data;
F[0,0,0] = 0.0083987;
F[0,0,1] = 0.01222470;
F[0,0,2] = 0.05272440;

...

end;

failed:
my.data:2: syntax error in data section

Thank you,

Yuri

_______________________________________________
Help-glpk mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-glpk

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]