Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Display of makespan

    Posted 05/10/18 06:26 AM

    Originally posted by: Ahlem


    Hi, 

    I'm working on the flexible job shop scheduling problem and the output of my program is the makespan using the command cp.getObjValue(). But, the display slows me down the execution.

    And, this is the code : 

    import java.util.List;
    import java.util.ArrayList;
    import ilog.concert.IloException;
    import ilog.concert.IloIntExpr;
    import ilog.concert.IloIntervalVar;
    import ilog.concert.cppimpl.IloObjective;
    import ilog.cp.*;
    
    public class evaluationCplex {
    
    
            public evaluationCplex() {
                    super();
            }
            
            static class IntervalVarList extends ArrayList<IloIntervalVar> {
            public IloIntervalVar[] toArray() {
                return (IloIntervalVar[]) this.toArray(new IloIntervalVar[this.size()]);
            }
        }
    
            static IloIntExpr[] arrayFromList(List<IloIntExpr> list) {
            return (IloIntExpr[]) list.toArray(new IloIntExpr[list.size()]);
        }
            public double modell(MatriceGlobal MG) throws IloException {
                                    
                    Information f = new Information();
                    MatriceGlobal benchmrak = f.getM();
                    int job = f.getNbjob();
                    int ressource = f.getNbressource();
                    int failLimit = 10000;
                    IloCP cp = new IloCP();
                    try {
                                                    
                            
                            IntervalVarList[] machines = new IntervalVarList[ressource];
                for (int j = 0; j < ressource; j++)
                    machines[j] = new IntervalVarList();
                List<IloIntExpr> ends = new ArrayList<IloIntExpr>();                    
                            IntervalVarList[] jobs = new IntervalVarList[job]; //hedhi mtaa l'affichage f solve()
                                                    
                                                                                                                                                                                                                                                                                    
                                    //Precedence constraints 
                                    
                                    for (int i = 0; i < job; i++) 
                                    {
                                            jobs[i] = new IntervalVarList();
                                            IloIntervalVar prec = cp.intervalVar();
                                            int[][] MatBinaire = MG.get(i).getMatrice();
                                            int[][] mat = benchmrak.get(i).getMatrice();
                                            for (int j = 0; j < MG.get(i).getX(); j++) //operation by job
                                            {
                                                    IloIntervalVar master = cp.intervalVar();
                                                    jobs[i].add(master);
                                                    IntervalVarList members = new IntervalVarList();
                                for (int k = 0; k < ressource; k++) 
                                            {
                                    if (MatBinaire[j][k] ==1) 
                                    {
                                                                    int duree = mat[j][k];
                                                                    IloIntervalVar member = cp.intervalVar(duree);
                                            member.setOptional();
                                            members.add(member);
                                            machines[k].add(member);
                                    
                                    }
                                            }
                                cp.add(cp.alternative(master, members.toArray()));
                                if (j > 0)
                                    cp.add(cp.endBeforeStart(prec, master));
                                prec = master;
                                            }
                                            
                                            ends.add(cp.endOf(prec)); //définir l'objectif de minimisation.                                      
    
                                    }
                                    
                                    for (int j = 0; j < ressource; j++) 
                                     {
                                    cp.add(cp.noOverlap(machines[j].toArray()));
                             }
                            
                            
                                IloObjective objective = (IloObjective) cp.minimize(cp.max(arrayFromList(ends)));
                        cp.add(objective);
                        cp.setParameter(IloCP.IntParam.FailLimit, failLimit);
    
                       if (cp.solve()) {
                            //System.out.println("Makespan \t: " + cp.getObjValue());     
                             
                        } else {
                            System.out.println("No solution found.");
                        }
    
    
                    } catch (IloException exc) {
                            exc.printStackTrace();
                    }
                    return (cp.getObjValue());
                    
            }
    }
    

    How can i display only the value of the makespan ? 

    Please help me. 

    Best regards. 

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Display of makespan

    Posted 05/10/18 03:49 PM

    I doubt that the time spent printing progress reports actually amounts to much, but in any case you can suppress it with the command cp.setOut(null).


    #CPLEXOptimizers
    #DecisionOptimization