0

I have a variable u[i,j,p] where i and j are ordered sets. Specifically I have defined the variable and the sets like

  set I;
  set J;
  set P;
  set LINKS within {I,J};
  param u{LINKS,P}

in the .mod file. In my .dat I've written:

set I := 1 2 3 4;
set J := Factory1 Factory2 Factory3 Factory4
set LINKS := (1,Factory1) (2,Factory1) (3,Factory2) (4,Factory2);
set P:= prod1 prod2 prod3;

param u default 0:=
     [1,Factory1,*] prod1 0.5251 prod2 0.3738
     [2,Factory1,*] prod1 0.5052 prod2 0.3311
     [3,Factory2,*] prod1 0.5555 prod3 0.6666
     [4,Factory2,*] prod3 0.6156 prod4 0.3353;

But this gives me errors regarding how u is declared. When trying to follow the AMPL documentation I tried to do

param LINKS: u:=
     [1,Factory1,*] prod1 0.5251 prod2 0.3738
     [2,Factory1,*] prod1 0.5052 prod2 0.3311
     [3,Factory2,*] prod1 0.5555 prod3 0.6666
     [4,Factory2,*] prod3 0.6156 prod4 0.3353;

But it also gives error.

halfer
  • 19,824
  • 17
  • 99
  • 186
Cenderze
  • 1,202
  • 5
  • 33
  • 56

1 Answers1

1

There are two issues in your code:

  1. Missing semicolons in

    param u{LINKS,P}
    

    and

    set J := Factory1 Factory2 Factory3 Factory4
    
  2. Use of prod4 which is not a member of P.

Otherwise it looks correct.

vitaut
  • 49,672
  • 25
  • 199
  • 336