Ich bekomme den folgenden out-of-Domain-Fehler, siehe unten. Die Sache ist, in der bezogenen Zeile kommt q aus dem Qua- litätssatz, der nicht einmal den LAT-Wert enthält. Wie kann ich dies verhindern und alle meine Daten in einer Tabelle speichern? Ich habe versucht, es mit der separaten Tabelle latdata
umgehen, aber das sieht hässlich und überflüssig für mich.Spalte, die nicht betrachtet werden soll, ist außerhalb der Domäne
$ glpsol -m ron.mod
GLPSOL: GLPK LP/MIP Solver, v4.60
Parameter(s) specified in the command line:
-m ron.mod
Reading model section from ron.mod...
Reading data section from ron.mod...
86 lines were read
Generating req...
ron.mod:20: cannot convert LAT to floating-point number
MathProg model processing error
MacBook-Air-van-Ron:examples raarts$ glpsol -m ron.mod
GLPSOL: GLPK LP/MIP Solver, v4.60
Parameter(s) specified in the command line:
-m ron.mod
Reading model section from ron.mod...
Reading data section from ron.mod...
86 lines were read
Generating req...
ron.mod:20: data[DO_MINI,LAT] out of domain
MathProg model processing error
die Quelle für ron.mod unter:
set AllProducts;
/* all products */
set Qualities;
/* minrequired */
param data{prod in AllProducts, {"price"} union Qualities};
param latdata{prod in AllProducts, "LAT"};
param maxallowed{"LAT"};
set Product := setof{ prod in AllProducts: latdata[prod, "LAT"] <= maxallowed["LAT"]} prod;
param minrequired{q in Qualities};
var x{p in Product}, integer, >= 0;
subject to req{q in Qualities}: sum{p in Product} data[p,q] * x[p] >= minrequired[q];
minimize cost: sum{p in Product} x[p] * data[p, "price"];
solve;
printf "aantal product CPU RAM DISK PR/STUK TOTAAL\n";
printf{p in Product: x[p] != 0} "%6d %-12s %6d %6d %6d %8.2f %8.2f\n", x[p], p, data[p,"CPU"] * x[p], data[p,"RAM"] * x[p], data[p,"DISK"] * x[p],data[p,"price"], data[p,"price"] * x[p];
printf "%6s %-12s %6d %6d %6d %8.2s %8.2f\n", "", "", sum{p in Product} data[p,"CPU"] * x[p], sum{p in Product} data[p,"RAM"] * x[p], sum{p in Product} data[p,"DISK"] * x[p], "", sum{p in Product} data[p,"price"] * x[p];
data;
param data : price CPU RAM DISK LAT :=
DO_MINI 5.00 1 512 20 2
DO_SMALL 10.00 2 1024 30 2
DO_MEDIUM 15.00 2 2048 40 2
DO_LARGE 25.00 3 4096 75 2
SW_MINI 5.00 1 1024 10 3
SW_SMALL 10.00 2 1024 15 3
SW_MEDIUM 15.00 2 2048 25 3
SW_LARGE 25.00 3 4096 50 3
BP_LARGE 5.00 3 4096 50 20
;
param latdata : LAT :=
DO_MINI 2
DO_SMALL 2
DO_MEDIUM 2
DO_LARGE 2
SW_MINI 3
SW_SMALL 3
SW_MEDIUM 3
SW_LARGE 3
BP_LARGE 20
;
set AllProducts :=
DO_MINI
DO_SMALL
DO_MEDIUM
DO_LARGE
SW_MINI
SW_SMALL
SW_MEDIUM
SW_LARGE
BP_LARGE
;
param minrequired :=
CPU 15
RAM 64000
DISK 1250
;
param maxallowed :=
LAT 5
;
set Qualities :=
CPU
RAM
DISK
;
end;