Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  scheduling with CP in C#

    Posted 05/18/16 03:22 PM

    Originally posted by: BabakArh


    I start to code a simple schduling problem

    5 job with p_time=4

    1 machine

    my obj is sum of completion time

    After I solve my model, I get 0 as start time for all jobs.

    here is my code

     

    /*
     * Created by SharpDevelop.
     * User: bbka2
     * Date: 05/18/2016
     * Time: 8:54 PM
     * 
     * To change this template use Tools | Options | Coding | Edit Standard Headers.
     */
    using System;
    using System.IO;
    using ILOG.CP;
    using ILOG.Concert;


    namespace test_here
    {
        /// <summary>
        /// Description of CMAX.
        /// </summary>
        public class CMAX
        {
            public IIntExpr makespan;
            public IIntervalVar[] act_;
            public IIntExpr[] end;
            public CP scheduler;
            public IObjective obj;
            public int n_;
            public CMAX()
            {
                initial();
                disp();
            }
            public void initial()
            {
                n_=5;
                scheduler=new CP();
                act_=new IIntervalVar[n_];
                makespan=scheduler.Constant(0,"MakeSpan");
                for (int i = 0; i < n_; i++) {
                    act_[i]=scheduler.IntervalVar(4,"act"+i.ToString());
                    act_[i].EndMax=30;
                    act_[i].EndMin=0;
                    act_[i].StartMax=30;
                    act_[i].StartMin=0;
                    act_[i].LengthMax=4;
                    act_[i].LengthMin=4;
                    Console.WriteLine(act_[i].ToString());
                    makespan=scheduler.Sum(makespan,scheduler.EndOf(act_[i]));
                    Console.WriteLine(makespan.ToString());
                }
                scheduler.NoOverlap(act_);
                scheduler.AddMinimize(makespan);
                scheduler.SetParameter(CP.IntParam.SearchType,CP.ParameterValues.DepthFirst);
            }
            public void disp()
            {
                if (scheduler.Solve()) {
                    //scheduler.Solve();
                    Console.WriteLine("this is th obj {0}",scheduler.ObjValue);
                    for (int i = 0; i < n_; i++) {
                        Console.WriteLine("the act {0}, has start {1}",i,scheduler.GetStart(act_[i]));
                    }
                }
            }
        }
    }


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: scheduling with CP in C#



  • 3.  Re: scheduling with CP in C#

    Posted 05/18/16 04:53 PM

    Originally posted by: BabakArh


    I wrote sum(p_time) for abject, it could give me 4+8+12+16+20

    and for the start time i get 0 for all. and it is wrong.

    is it wrong what I code which gave me 0 for start time?


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: scheduling with CP in C#

    Posted 05/19/16 04:13 AM

    Originally posted by: BabakArh


    I thinl My refrences doesnt work at all

     

     

    I add this constraint to force cp, to change the start times but it doesnt work either

     

    for (int i = 0; i < n_; i++) {
                    for (int j = 0; j < i; j++) {
                        scheduler.Or(scheduler.Le(scheduler.EndOf(act_[i]),scheduler.StartOf(act_[j]))
                                     ,scheduler.Le(scheduler.EndOf(act_[j]),scheduler.StartOf(act_[i])));
                    }
                }


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: scheduling with CP in C#

    Posted 05/20/16 12:09 PM

    Originally posted by: GGR


    Hi

     

    You have only created the constraint. You have to explicitly add the constraint to the solver. Please have a look on:

    http://www.ibm.com/support/knowledgecenter/SSSA5P_12.6.3/ilog.odms.cpo.help/CP_Optimizer/User_manual/topics/model_formulating.html?lang=fr

     

    The reason why is that you can manipulate the constraint in other way than pure condition to verify to a solution, for example writing complex Boolean expressions.

     

    Hope that helps

     

     


    #CPOptimizer
    #DecisionOptimization


  • 6.  Re: scheduling with CP in C#

    Posted 05/20/16 03:45 PM

    Originally posted by: BabakArh


    about the constraint u r right. i add the constraint to model it worked.

    Thank u.

     

    that means even all global constraint has to be written like this

     

    iConstraint ct=model.noOverlap(iInterval[]);

    model.add(ct);


    #CPOptimizer
    #DecisionOptimization