|
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 |
You can define a data block like this:Hi, Yuri!
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. NevesEm 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
[Prev in Thread] | Current Thread | [Next in Thread] |