piecewise linear approximation - 148 dimension different

Hello,

I send you my code below, I keep getting the error “148 Dimension different - The symbol is referenced with more/less indices as declared”
where y1 occurs.

thank you in advance for your help.

basak


$title THE TIRE TREAD COMPOUND PROBLEM

option limrow = 0,
limcol = 0
;


Sets

i index of factors /13/
j index of responses /1
2/
k index of responses /1*2/ ;

  •    t index of linearization variables/1*3/;
    
  • this contains the set of points

set notlastx1(i) ;
notlastx1(i)$(ord(i) lt card(i)) = yes ;

set notlastx2(i) ;
notlastx2(i)$(ord(i) lt card(i)) = yes ;

set notlastx3(i) ;
notlastx3(i)$(ord(i) lt card(i)) = yes ;

set notlastg1(i) ;
notlastg1(i)(ord(i) lt card(i)) = yes ; set notlastg2(i) ; notlastg2(i)(ord(i) lt card(i)) = yes ;
set notlastg3(i) ;
notlastg3(i)$(ord(i) lt card(i)) = yes ;

set notlastg4(i) ;
notlastg4(i)(ord(i) lt card(i)) = yes ; set notlastg5(i) ; notlastg5(i)(ord(i) lt card(i)) = yes ;

set notlastg6(i) ;
notlastg6(i)$(ord(i) lt card(i)) = yes ;

Parameters
xval1(i)/
1 -1
2 0
3 1 /
xval2(i)/
1 -1
2 0
3 1 /
xval3(i)/
1 -1
2 0
3 1 /
gval1(i)/
1 -1
2 0
3 1
/

gval2(i)/
1 -1
2 0
3 1
/
gval3(i)/
1 -1
2 0
3 1
/
gval4(i)/
1 -1
2 0
3 1
/
gval5(i)/
1 -1
2 0
3 1
/
gval6(i)/
1 -1
2 0
3 1
/;

parameters yval1(i), yval2(i),yval3(i),gyval1(i),gyval2(i),gyval3(i),gyval4(i),gyval5(i),gyval6(i);
yval1(i) = sqr(xval1(i)) ;
yval2(i) = sqr(xval2(i)) ;
yval3(i) = sqr(xval3(i)) ;
gyval1(i) = sqr(gval1(i)) ;
gyval2(i) = sqr(gval2(i)) ;
gyval3(i) = sqr(gval3(i)) ;
gyval4(i) = sqr(gval4(i)) ;
gyval5(i) = sqr(gval5(i)) ;
gyval6(i) = sqr(gval6(i)) ;


variables w1(j),w2(j),x1,x2,x3,g1,g2,g3,g4,g5,g6,y1,y2,y3,gy1,gy2,gy3,gy4,gy5,gy6,lamx1(i),lamx2(i),lamx3(i),lamg1(i),lamg2(i)
lamg3(i),lamg4(i),lamg5(i),lamg6(i),binx1(i),binx2(i),binx3(i),bing1(i),bing2(i),bing3(i),bing4(i),bing5(i),bing6(i)
D
p objective function
Y1(k)
Y(j) responses;


positive variables lamx1(i),lamx2(i),lamx3(i),lamg1(i),lamg2(i)
lamg3(i),lamg4(i),lamg5(i),lamg6(i) ;
binary variables zj1,zj2, binx1(i),binx2(i),binx3(i),bing1(i),bing2(i),bing3(i),bing4(i),bing5(i),bing6(i) ;



p.lo=0;



TABLE yDATA1(k,*) One-sided Response Bounds


yMIN1 yMAX1 A1 B1 C1 D1 E1 F1 G1 H1 J1 K1

1 50.38 242.69 139.11924 16.49364 17.88077 10.90654 -4.00960 -3.44711 -1.57212 5.12500 7.12500 7.87500
2 7.31 3019.23 1261.13314 268.15110 246.50317 139.48453 -83.56588 -124.81554 199.18175 69.37500 94.12500 104.37500;

  •                   b0            x1          x2           x3           x1^2         x2^2          x3^2        x1x2      x1x3        x2x3
    

TABLE yDATA(j,*) Two-sided Response Bounds

yMIN yMAX Ty A B C D E F G H J K

1 400 600 500 400.38458 -99.66642 -31.39639 -73.91900 7.93269 17.30761 0.43275 8.75 6.25 1.25
2 57.66 87.73 67.5 68.90962 -1.40985 4.31969 1.63484 1.55768 0.057694 -0.31730 -1.62500 0.12500 -0.25000;

  •                               b0         x1             x2        x3        x1^2     x2^2      x3^2      x1x2     x1x3     x2x3
    
  •                           b0            x1          x2           x3           x1^2        x2^2          x3^2        x1x2      x1x3        x2x3
    

Equations

COST objective function

  •     binarcons(j)         constraint for binary variable
    
  •      cons(j)
    
  •     consa(j)
    

subfunc(j)
subfunc1(k)

x1def, gx1def, x2def, gx2def, x3def, gx3def,gx4def,gx5def,gx6def,y1def
y2def,y3def, gy1def,gy2def,gy3def, gy4def, gy5def,gy6def
normx1,normx2,normx3,normgx1,normgx2,normgx3,normgx4,normgx5,normgx6
lamdefx1(i),lamdefx2(i),lamdefx3(i),lamdefg1(i),lamdefg2(i),lamdefg3(i),lamdefg4(i),lamdefg5(i),lamdefg6(i)
soslamx1,soslamx2,soslamx3,soslamg1,soslamg2,soslamg3,soslamg4,soslamg5,soslamg6

  •  descons11(j)
    
  • descons12(j);
    descons1(j)
    descons2(j)
    descons3(j)
    descons4(j)
    descons5(j)
    descons6(j)
    descons7(j)
    descons8(j)
    descons9(j)
    descons10(k)
    cons1
    cons2
    cons3
    cons4
    cons5
    cons6 ;


    COST… D=e=p;



    cons1… x1+x2=e=g1;
    cons2… x1-x2=e=g2;
    cons3… x1+x3=e=g3;
    cons4… x1-x3=e=g4;
    cons5… x2+x3=e=g5;
    cons6… x2-x3=e=g6;



    x1def… x1 =e= sum(i,lamx1(i)*xval1(i)) ;
    y1def… y1 =e= sum(i,lamx1(i)*yval1(i)) ;

x2def… x2 =e= sum(i,lamx2(i)*xval2(i)) ;
y2def… y2 =e= sum(i,lamx2(i)*yval2(i)) ;

x3def… x3 =e= sum(i,lamx3(i)*xval3(i)) ;
y3def… y3 =e= sum(i,lamx3(i)*yval3(i)) ;

gx1def… g1 =e= sum(i,lamg1(i)*gval1(i)) ;
gy1def… gy1 =e= sum(i,lamg1(i)*gyval1(i)) ;

gx2def… g2 =e= sum(i,lamg2(i)*gval2(i)) ;
gy2def… gy2 =e= sum(i,lamg2(i)*gyval2(i)) ;

gx3def… g3 =e= sum(i,lamg3(i)*gval3(i)) ;
gy3def… gy3 =e= sum(i,lamg3(i)*gyval3(i)) ;

gx4def… g4 =e= sum(i,lamg4(i)*gval4(i)) ;
gy4def… gy4 =e= sum(i,lamg4(i)*gyval4(i)) ;

gx5def… g5 =e= sum(i,lamg5(i)*gval5(i)) ;
gy5def… gy5 =e= sum(i,lamg5(i)*gyval5(i)) ;

gx6def… g6 =e= sum(i,lamg6(i)*gval6(i)) ;
gy6def… gy6 =e= sum(i,lamg6(i)*gyval6(i)) ;


normx1… sum(i,lamx1(i)) =e= 1 ;
normx2… sum(i,lamx2(i)) =e= 1 ;
normx3… sum(i,lamx3(i)) =e= 1 ;

normgx1… sum(i,lamg1(i)) =e= 1 ;
normgx2… sum(i,lamg2(i)) =e= 1 ;
normgx3… sum(i,lamg3(i)) =e= 1 ;
normgx4… sum(i,lamg4(i)) =e= 1 ;
normgx5… sum(i,lamg5(i)) =e= 1 ;
normgx6… sum(i,lamg6(i)) =e= 1 ;

lamdefx1(i)… lamx1(i) =l= binx1(i-1) + binx1(i)$notlastx1(i) ;
soslamx1… sum(i$notlastx1(i),binx1(i)) =e= 1 ;

lamdefx2(i)… lamx2(i) =l= binx2(i-1) + binx2(i)$notlastx2(i) ;
soslamx2… sum(i$notlastx2(i),binx2(i)) =e= 1 ;

lamdefx3(i)… lamx3(i) =l= binx3(i-1) + binx3(i)$notlastx3(i) ;
soslamx3… sum(i$notlastx3(i),binx3(i)) =e= 1 ;

lamdefg1(i)… lamg1(i) =l= bing1(i-1) + bing1(i)$notlastg1(i) ;
soslamg1… sum(i$notlastg1(i),bing1(i)) =e= 1 ;

lamdefg2(i)… lamg2(i) =l= bing2(i-1) + bing2(i)$notlastg2(i) ;
soslamg2… sum(i$notlastg2(i),bing2(i)) =e= 1 ;

lamdefg3(i)… lamg3(i) =l= bing3(i-1) + bing3(i)$notlastg3(i) ;
soslamg3… sum(i$notlastg3(i),bing3(i)) =e= 1 ;

lamdefg4(i)… lamg4(i) =l= bing4(i-1) + bing4(i)$notlastg4(i) ;
soslamg4… sum(i$notlastg4(i),bing4(i)) =e= 1 ;

lamdefg5(i)… lamg5(i) =l= bing5(i-1) + bing5(i)$notlastg5(i) ;
soslamg5… sum(i$notlastg5(i),bing5(i)) =e= 1 ;

lamdefg6(i)… lamg6(i) =l= bing6(i-1) + bing6(i)$notlastg6(i) ;
soslamg6… sum(i$notlastg6(i),bing6(i)) =e= 1 ;


subfunc(j)… (yDATA(j,‘A’)+yDATA(j,‘B’)*x1+yDATA(j,‘C’)*x2+yDATA(j,‘D’)*x3+
yDATA(j,‘E’)y1+yDATA(j,‘F’)y2+yDATA(j,‘G’)y3
+yDATA(j,‘H’)
(gy1-gy2)+yDATA(j,‘J’)
(gy3-gy4)+yDATA(j,‘K’)
(gy5-gy6)) =e= Y(j);

subfunc1(k)… (yDATA1(k,‘A1’)+yDATA1(k,‘B1’)*x1+yDATA1(k,‘C1’)*x2+yDATA1(k,‘D1’)*x3+
yDATA1(k,‘E1’)y1+yDATA1(k,‘F1’)y2+yDATA1(k,‘G1’)y3+yDATA1(k,‘H1’)(gy1-gy2)
+yDATA1(k,‘J1’)
(gy3-gy4)+yDATA1(k,‘K1’)
(gy5-gy6)) =e= Y1(k);

descons1(j)… w1(j)+w2(j)=g=p;
descons2(j)… w1(j)=l=zj1;
descons3(j)… w1(j)=g=0;
descons4(j)… w1(j)=l=((Y(j)-yDATA(j,‘yMIN’))/(yDATA(j,‘Ty’)-yDATA(j,‘yMIN’)));
descons5(j)… w1(j)=g=zj1+((Y(j)-yDATA(j,‘yMIN’))/(yDATA(j,‘Ty’)-yDATA(j,‘yMIN’)))-1;
descons6(j)… w2(j)=l=zj2;
descons7(j)… w2(j)=g=0;
descons8(j)… w2(j)=l=((Y(j)-yDATA(j,‘yMAX’))/(yDATA(j,‘Ty’)-yDATA(j,‘yMAX’)));
descons9(j)… w2(j)=g=zj2+((Y(j)-yDATA(j,‘yMAX’))/(yDATA(j,‘Ty’)-yDATA(j,‘yMAX’)))-1;





descons10(k)… (Y1(k)-yDATA1(k,‘yMIN1’))/(yDATA1(k,‘yMAX1’)-yDATA1(k,‘yMIN1’))=g=p;



x1.lo = smin(i,xval1(i)) ;
x1.up = smax(i,xval1(i)) ;
x2.lo = smin(i,xval1(i)) ;
x2.up = smax(i,xval1(i)) ;
x3.lo = smin(i,xval1(i)) ;
x3.up = smax(i,xval1(i)) ;
g1.lo = smin(i,gval1(i)) ;
g1.up = smax(i,gval1(i)) ;
g2.lo = smin(i,gval2(i)) ;
g2.up = smax(i,gval2(i)) ;
g3.lo = smin(i,gval3(i)) ;
g3.up = smax(i,gval3(i)) ;
g4.lo = smin(i,gval4(i)) ;
g4.up = smax(i,gval4(i)) ;
g5.lo = smin(i,gval5(i)) ;
g5.up = smax(i,gval5(i)) ;
g6.lo = smin(i,gval6(i)) ;
g6.up = smax(i,gval6(i)) ;
MODEL xz /ALL/;



option mip=cplex;
xz.optcr = 0.0 ;

SOLVE xz USING mip MAXIMIZING D;

DISPLAY x1.l,x2.l,x3.l;