Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a multidimensional variable in ilog with Java interface?

Tags:

cplex

ilog

I want to model a problem with a variable x[i][j][k].

No where in the reference manual is there mention of how to create a variable with size greater than 1 dimension.

http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r4/index.jsp?topic=%2Filog.odms.cplex.help%2Frefjavacplex%2Fhtml%2Filog%2Fcplex%2FIloCplex.html

like image 743
Unlucky_faust Avatar asked Jul 16 '26 03:07

Unlucky_faust


1 Answers

This snippet shows an example of creating three indexed continuous variable x, x[i][j][t] in [0,1]:

  IloNumVar[][][] x = new IloNumVar[numNodes][numNodes][numDays];
  for(int i = 0; i < numNodes; i++) 
  {
    for(int j = 0; j < numNodes; j++)
    {
      //cplex is an instance of class IloCplex
      x[i][j] = cplex.numVarArray(numDays, 0, 1); 
    }
  }
like image 56
user327301 Avatar answered Jul 21 '26 18:07

user327301



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!