public Schedule(ProblemInstance prob, Random rnd = null, string slotAllocation = "FirstSlotChosen") { _prob = prob; Sequence = new List<Dispatch>(prob.Dimension); _jobs = new Jobs[_prob.NumJobs]; _macs = new Macs[_prob.NumMachines]; ReadyJobs = new List<int>(_prob.NumJobs); for (int job = 0; job < _prob.NumJobs; job++) { ReadyJobs.Add(job); int totalWork = 0; for (int a = 0; a < _prob.NumMachines; a++) totalWork += _prob.Procs[job, a]; _jobs[job] = new Jobs(job, totalWork, _prob.NumMachines); _totProcTime += totalWork; // total work for all jobs (is equivalent to total work for all machines) } for (int mac = 0; mac < _prob.NumMachines; mac++) { int totalWork = 0; for (int j = 0; j < _prob.NumJobs; j++) totalWork += _prob.Procs[j, mac]; _macs[mac] = new Macs(mac, totalWork); } _slotAllocation = slotAllocation.Substring(0, 5).ToLower().Equals("first") ? (Func<int[], int, int, int>) FirstSlotChosen : SmallestSlotChosen; if (rnd == null) { int seed = (int) DateTime.Now.Ticks; _random = new Random(seed); } else _random = rnd; }
private GRBVar[,] _x; // starting time of job j on machine a #endregion Fields #region Constructors public GurobiJspModel(ProblemInstance prob, string name, int tmlim_min) { _n = prob.NumJobs; _m = prob.NumMachines; Info = "Starting gurobi optimisation"; _fileName = String.Format("jssp.{0}.log", name); // Model try { _env = new GRBEnv(_fileName); if (tmlim_min > 0) _env.Set(GRB.DoubleParam.TimeLimit, tmlim_min*60); // time limit is set to seconds! _env.Set(GRB.IntParam.LogToConsole, 0); _model = new GRBModel(_env); _model.Set(GRB.StringAttr.ModelName, "jsp"); } catch (GRBException e) { Console.WriteLine("Error code: " + e.ErrorCode + ". " + e.Message); } DecisionVariables(); ProcessingOrder(prob.Procs, prob.Sigma); DisjunctiveCondition(prob.Procs); Objective(prob.Procs, prob.Sigma); //TrueOptimumDecVars = Optimise(out TrueOptimum); //if (TrueOptimum > 0) // Objective cutoff // _model.GetEnv().Set(GRB.DoubleParam.Cutoff, TrueOptimum + 0.5); /* Indicates that you aren't interested in solutions whose objective values * are worse than the specified value. If the objective value for the optimal * solution is better than the specified cutoff, the solver will return the * optimal solution. Otherwise, it will terminate with a CUTOFF status. */ // seems to be only for LP relaxation, not MIP objective }
private void AddProblem(ProblemInstance prob, string givenName) { if (prob == null) return; var pid = ++NumInstances; var row = Data.NewRow(); row["Name"] = GetName(pid); row["PID"] = pid; row["Problem"] = prob; row["GivenName"] = givenName; Data.Rows.Add(row); }
private static string Problem2String(ProblemInstance prob) { var thisProblem = prob.NumJobs + " " + prob.NumMachines + "\n"; for (var j = 0; j < prob.NumJobs; j++) { for (var m = 0; m < prob.NumMachines; m++) { thisProblem += prob.Sigma[j, m] + " " + prob.Procs[j, m] + " "; } thisProblem += "\n"; } return thisProblem; }