Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Implementation cplex; java

    Posted 04/21/18 07:04 PM

    Originally posted by: Ahlem


    I would like to implement the following MILP in Java CPLEX.

    • So, this is the notation:  

    • My decision variable : 

    • Can some one help with the implementation part of this MILP problem?

    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Implementation cplex; java

    Posted 04/22/18 03:19 AM

    And what is your question or problem?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Implementation cplex; java

    Posted 04/22/18 03:16 PM

    Originally posted by: Ahlem


    Yes my question is when we have sums in the constraints influences on the writing of the code and the final result?

    To better understand me, take the constraint 4 does this code below give the same result?

    // the first possibility
    for (int i2 = 0; i2 < job; i2++) {
                                            
                                            IloLinearNumExpr[][][] expr = new IloLinearNumExpr[job][MG.get(m).get(i2).getX()][ressource];
                                            IloLinearNumExpr[][][] expr1 = new IloLinearNumExpr[job][MG.get(m).get(i2).getX()][ressource];
                                            for (int j2 = 0; j2 < MG.get(m).get(i2).getX(); j2++) {
                                                                                                    
                                                    for (int k = 0; k < ressource; k++) {
    
                                                            expr[i2][j2][k] = cplex.linearNumExpr();
                                                            expr1[i2][j2][k] = cplex.linearNumExpr();
                                                            
                                                            for (int i1 = 0; i1 < job; i1++) {
    
                                                                    for (int j1 = 0; j1 < MG.get(m).get(i1).getX(); j1++) {
                                                                    
                                                                            expr[i2][j2][k].addTerm(1.0, y[i1][j1][i2][j2][k]);     
                                                                            expr1[i2][j2][k].addTerm(1.0, y[i2][j2][i1][j1][k]);
                                                                    
                                                                    }
                                                                    
                                                            }
                                                            
                                                            cplex.addLe(expr[i2][j2][k], 1); //Constraint3
                                                            cplex.addLe(expr[i2][j2][k], expr1[i2][j2][k]); //Constaint4 
                                                            
                                                    }
                                            }
                                    }
                                    
                                    
    
    // the second possibility
    
    for (int i1 = 0; i1 < job; i1++) {
    
                                            for (int j1 = 0; j1 < MG.get(m).get(i1).getX(); j1++) {
    
                                                    for (int i2 = 0; i2 < job; i2++) {
    
                                                            for (int j2 = 0; j2 < MG.get(m).get(i2).getX(); j2++) {
                                                                    
                                                                    for (int k = 0; k < ressource; k++) {
                                                                            
                                                                            IloLinearNumExpr expr = cplex.linearNumExpr(); // constraint3                                                                                                                                                                    
                                                                            expr.addTerm(1.0, y[i1][j1][i2][j2][k]);
                                                                            cplex.addLe(expr, 1);
    
                                                                            IloLinearNumExpr expr1 = cplex.linearNumExpr(); // constraint4
                                                                            expr1.addTerm(1.0, y[i2][j2][i1][j1][k]);
                                                                            cplex.addLe(expr, expr1);
    
                                                                    }
                                                            }
                                                    }
                                            }
                                    }
    

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Implementation cplex; java

    Posted 04/26/18 04:57 AM

    I did not check all the indices in detail but in principle your first variant looks correct while the second one is almost certainly wrong.


    #CPLEXOptimizers
    #DecisionOptimization