WannaBle
WannaBle

Reputation: 1

Unknown error in CPLEX

int n = 3;

{int} s = asSet(0..n);

int maxTG = 15;


tuple Node {
  int xPoint;
  int yPoint;
    }

{Node} Nodes=...;

tuple Demand {
  key string index;
  Node StartNode;
  Node FinalNode;
}



{Demand} Demands= ...;


int t[Nodes][Nodes] = ...;

int CI = 100;
int CO = 10;
int B=5;
int K=3;

dvar boolean x[Demands];
dvar boolean xs[Demands][Nodes];
dvar boolean xf[Demands][Nodes]; // Final Location of Demand
dvar boolean y[Nodes]; //Facility Location
dvar boolean xsd[Demands][Nodes][Nodes];
dvar boolean xfd[Demands][Nodes][Nodes];
dvar boolean x3[Demands][Nodes][Nodes];

//objective function

maximize sum(d in Demands) x[d];

// subject to

subject to {
  forall ( d in Demands ) {
    sum(i in Nodes) xs[d][i] <= 1 ;
    sum(i in Nodes) xf[d][i] <= 1 ; } //2

  forall (d in Demands, i in Nodes) {
    xs[d][i] <= y[i] ;
    xf[d][i] <= y[i];} //4

  forall (d in Demands, i in Nodes) {
    xs[d][i] * t[i][d.StartNode] <= maxTG; //5
    xf[d][i] * t[i][d.FinalNode]  <= maxTG; }  //6

  forall (d in Demands, i,j in Nodes : i!=j ) {
    xs[d][i] * t[i][d.StartNode] <= t[j][d.StartNode] * y[j]; //7
    xf[d][i] * t[i][d.FinalNode] <= t[j][d.FinalNode] * y[j]; //8
  }  

  forall (d in Demands) {
    x[d] <= sum(i in Nodes) xs[d][i];//9
    x[d] <= sum(i in Nodes) xf[d][i]; //10 
    sum(i in Nodes) xs[d][i] + sum(i in Nodes ) xf[d][i] - 1 <= x[d]; } //11



 CI * sum ( i in Nodes) y[i] + CO * sum ( i in Nodes, d in Demands ) ( xs[d][i] + xf[d][i] ) <= B;

  forall (i in Nodes)
    sum (d in Demands) (xs[d][i] + xf[d][i]) <= K  ;


  forall (d in Demands, i,j in Nodes) {
    x3[d][i][j]<=xs[d][i]; //16
    x3[d][i][j]<=xf[d][i]; //17 
xs[d][i] + xf[d][i] - 1 <= x3[d][i][j]; } //18

  forall (d in Demands, i,j in Nodes : i!=j) {
    xsd[d][i][j] <= xs[d][i]; // 19 
    xsd[d][i][j] <= y[j];  // 20
    xs[d][i] + y[j] -1 <= xsd[d][i][j]; //21
    xfd[d][i][j] <= xf[d][i];
    xfd[d][i][j] <= y[j];
    xf[d][i] + y[j] -1 <= xfd[d][i][j]; }

enter image description here

After I 'run' this with dat file, this error appears but I can't figure out why this error comes out. Is there anyone who knows about this error? And cause this code is my first code in CPLEX SO plz give me any advice about this code. thx plz plz help me plz plz anyone help me plz plz ( the site wants me to add some more details...)

Upvotes: 0

Views: 110

Answers (1)

Alex Fleischer
Alex Fleischer

Reputation: 10062

I would add a "}" at the end of your .mod. You have not closed your subject to block.

Upvotes: 1

Related Questions