Originally posted by: BabakArh
I code the exact example of, IBM tutorial in C#. the objective value, and start time of interval is wrong. I think the lib dont work for me. it return 20 for obj and 0 for all interval start
the problem minimize MAKE SPAN for scheduling problem.
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]));
}
}
}
}
}
#DecisionOptimization#OPLusingCPLEXOptimizer