Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How to make a general array

    Posted 11/28/11 03:47 AM

    Originally posted by: SystemAdmin


    I need to make an array and the output should be like this
    for k=1 to 10
    X[1][1][k]
    X[2][1][k]
    X[3][1][k]
    X[4][1][k]
    X[5][1][k]
    X[6][1][k]
    X[1][2][k]
    X[2][2][k]
    X[3][2][k]
    X[1][3][k]
    X[2][3][k]
    X[3][3][k]

    How do i write this as general form
    X[i]j][k]
    #DecisionOptimization
    #MathematicalProgramming-General


  • 2.  Re: How to make a general array

    Posted 11/28/11 02:13 PM

    Originally posted by: SystemAdmin


    Per your requirements, it looks like the size of the decision variable is not uniform across all the dimensions. Assuming that X is a dvar, I would suggest you to declare it with the maximum size on each dimension and then only iterate over the indexes that you need in the constraints. That ways, even though you declare some indexes that are not actually used in the model, the presolver will eliminate them before solving the model thus having minimal effect on the performance. One such declaration could look like the following:

    
    range i = 1..6; range j = 1..3; range k = 1..10;   dvar int+ X[i][j][k];
    


    Hope this helps.
    #DecisionOptimization
    #MathematicalProgramming-General


  • 3.  Re: How to make a general array

    Posted 11/28/11 10:34 PM

    Originally posted by: SystemAdmin


    then how about this case.How do i write if staments inside the for loop in CPLEX

    forall (k in 1..t)
    forall (i in 1..N)
    forall (j in 1..B){
    d[j][i][0]==0;

    d[j][i][k]==D[j][i][k]+d[j][i]k-1;

    if i=1 and j=1..3

    c[j][i][0]==0;
    x[j][i][0]==0;

    c[j][i][k]==C[j][i][k]+c[j][i]k-1;
    x[j][i][k]==X[j][i][k]+x[j][i]k-1;

    if i=2 and j=1..3

    d[j][i][k]==D[j][i][k]+d[j][i]k-1;
    c[j][i][k]==C[j][i][k]+c[j][i]k-1;
    x[j][i][k]==X[j][i][k]+x[j][i]k-1;

    d[B][i]k-1>=C[1][i][k];
    c[B][i]k-1>=X[1][i][k];

    }
    #DecisionOptimization
    #MathematicalProgramming-General