Beispiel #1
0
 // sequence is a list of <job,mac,starttime>
 public int[,] Optimize(string name, out int optMakespan, out bool success,
     out int simplexIterations, int tmlim_min, List<Schedule.Dispatch> constraints = null)
 {
     GurobiJspModel model = new GurobiJspModel(this, name, tmlim_min);
     var xTimeJob = constraints != null
         ? model.Lookahead(constraints, out optMakespan)
         : model.Optimise(out optMakespan);
     simplexIterations = model.SimplexIterations;
     success = model.Status == GRB.Status.OPTIMAL;
     model.Dispose();
     return xTimeJob;
 }
Beispiel #2
0
 private List<Preference> FindFeaturesForAllJobs(Schedule jssp, GurobiJspModel gurobiModel)
 {
     Preference[] prefs = new Preference[jssp.ReadyJobs.Count];
     for (int r = 0; r < jssp.ReadyJobs.Count; r++)
     {
         Schedule lookahead = jssp.Clone();
         Features phi = lookahead.Dispatch1(jssp.ReadyJobs[r], FeatureMode, null); // commit the lookahead
         prefs[r] = new Preference(lookahead.Sequence[lookahead.Sequence.Count - 1], phi);
         // need to optimize to label featuers correctly -- this is computationally intensive
         gurobiModel.Lookahead(prefs[r].Dispatch, out prefs[r].ResultingOptMakespan);
         prefs[r].SimplexIterations = gurobiModel.SimplexIterations;
     }
     return prefs.ToList();
 }
Beispiel #3
0
        internal string CollectAndLabel(int pid)
        {
            string name = GetName(pid);
            DataRow instance = Data.Rows.Find(name);
            ProblemInstance prob = (ProblemInstance) instance["Problem"];

            GurobiJspModel gurobiModel = new GurobiJspModel(prob, name, TMLIM_STEP);

            Schedule jssp = new Schedule(prob);
            int currentNumFeatures = 0;
            for (int step = 0; step < prob.Dimension; step++)
            {
                Preferences[pid - 1, step] = FindFeaturesForAllJobs(jssp, gurobiModel);
                int dispatchedJob = _trajectory(jssp, Preferences[pid - 1, step]);
                jssp.Dispatch1(dispatchedJob);
                gurobiModel.CommitConstraint(jssp.Sequence[step], step);
                Preferences[pid - 1, step].Find(x => x.Dispatch.Job == dispatchedJob).Followed = true;
                currentNumFeatures += Preferences[pid - 1, step].Count;
            }
            NumFeatures += currentNumFeatures;
            gurobiModel.Dispose();
            RankPreferences(pid);
            return String.Format("{0}:{1} #{2} phi", FileInfo.Name, pid, currentNumFeatures);
        }