Schedulling Algorithm , one machine multiple locations

Viewed 33

I am currently trying to code a MIP problem in c#. I have one machine which does two types of tasks, these tasks take place in different locations. These locations are basically slots in racks. I am trying to find the best locations in order to minimize the makespan of the machine.

As I am very new to programming and cplex I am finding it very hard to find the best algorithm and how to define my data. I am assuming I can define the type of tasks as two different sets 1....n , but how I can define the positions, the positions have coordinates ( example column 1 row 3) . Should I define them as a matrix ?

As for the algorithm, I am assuming is a simple one-machine scheduling problem, but haven't find something similar, to boost me somehow.

Thank you in advance.

1 Answers

Within CPLEX, let me remind you that you have a scheduling engine : CPOptimizer.

You even have a C# API for that engine. See example ./examples/src/csharp/SchedJobShop.cs

CP cp = new CP();
            DataReader data = new DataReader(filename);

            nbJobs = data.Next();
            nbMachines = data.Next();
            List<IIntExpr> ends = new List<IIntExpr>();
            List<IIntervalVar>[] machines = new List<IIntervalVar>[nbMachines];
            for (int j = 0; j < nbMachines; j++)
                machines[j] = new List<IIntervalVar>();

            for (int i = 0; i < nbJobs; i++)
            {
                IIntervalVar prec = cp.IntervalVar();
                for (int j = 0; j < nbMachines; j++)
                {
                    int m, d;
                    m = data.Next();
                    d = data.Next();
                    IIntervalVar ti = cp.IntervalVar(d);
                    machines[m].Add(ti);
                    if (j > 0)
                    {
                        cp.Add(cp.EndBeforeStart(prec, ti));
                    }
                    prec = ti;
                }
                ends.Add(cp.EndOf(prec));
            }

            for (int j = 0; j < nbMachines; j++)
                cp.Add(cp.NoOverlap(machines[j].ToArray()));

            IObjective objective = cp.Minimize(cp.Max(ends.ToArray()));
            cp.Add(objective);

            Console.WriteLine("Instance \t: " + filename);
            if (cp.Solve())
            {
                Console.WriteLine("Makespan \t: " + cp.ObjValue);
            }
            else
            {
                Console.WriteLine("No solution found.");
            }
Related