Hello,
i got a table b(i,j) which looks like that:
j1 j2 j3 j4 j5 j6 j7 j8 j9
i1 1 0 0 1 0 0 0 1 1
i2 0 1 1 0 0 0 1 0 0
i3 0 1 0 0 1 0 0 0 1
i4 1 0 0 0 0 1 0 0 1
i5 0 0 0 0 0 0 1 1 1
i6 0 0 1 1 0 1 0 0 0
and i got a function F for costs that need to be minimized …
Now i want a restriction that says the sum of each row is exactly 1 and the model shall tell me which j’s are to be used.
I wrote a script in which everything works except for this restriction. The restriction is called NB… in the script. I am pretty sure I need an alias in some way but i cannot get it run without errors … would be very thankful for any help!
Here’s the script:
$title Bonusaufgabe
Sets
i Altersgruppen /i1i6/
j Medientypen /j1j9/;
alias(i,t)
;
Parameter
r(j) Kosten fuer j /j1 20000, j2 45000, j3 60000, j4 45000, j5 30000, j6 55000, j7 52000, j8 60000, j9 105000/
a(i) Beschränkung jeder Altersgruppe i /i1 1, i2 1, i3 1, i4 1, i5 1, i6 1/
;
table b(i,j)
$include Altersgruppen.txt
;
Variables
ZF Zielfunktionswert
;
positive variables
x(j) gewählte Menge von Medientypen j
;
Equations
ZFkt1 Zielfunktion
NB Nebenbedingung
;
ZFkt1…
ZF =e= sum((j,i), r(j) * x(j));
NB…
sum(t$(ord(t)<=ord(i)), b(j,t)) =e= a(t);
model Bonusaufgabe /ZFkt1,NB/;
solve Bonusaufgabe minimizing ZF using LP;
display ZF.l;