Home > OS >  Why is it showing like "Type range cannot be used for int" in C-PLEX programming?
Why is it showing like "Type range cannot be used for int" in C-PLEX programming?

Time:01-06

forall(i in nbus,j in tavail,k in nport)
  {ct3:if(soc[k][j]<=0.3&&pt[i][j]<pl[i][j])
     { pbatch[j][k]-(0.7-soc[k][j])*100000==0;}
      else
      {pbatch[j][k]==0;}}

pbatch is a decision variable. When I assign a value to pbatch, it is showing that I cannot use the type range for int.

Expecting to remove the error

CodePudding user response:

range nbus=1..1;
range tavail=1..3;
range nport=1..4;

int soc[k in nport][j in tavail]=rand(2);
int pl[i in nbus][j in tavail]=rand(4);
int pt[i in nbus][j in tavail]=rand(10);


dvar float  pbatch[tavail][nport];



subject to
{

forall(i in nbus,j in tavail,k in nport)
  {ct3:if(soc[k][j]<=0.3&&pt[i][j]<pl[i][j])
     { pbatch[j][k]-(0.7-soc[k][j])*100000==0;}
      else
      {pbatch[j][k]==0;}}
      
    }     

works fine

  • Related