public Dictionary <string, string> Solve(bool tune, bool debug, string tuneOutputFile = null, string paramFile = null) { var times = new Dictionary <string, string>(); var totalTime = Utils.TimeAction(() => { try { // Create an empty environment, set options and start GRBEnv env = new GRBEnv(true); // Use gurobi's parameter reader to load the best file if (paramFile != null) { env.ReadParams(paramFile); } if (!debug) { env.Set(GRB.IntParam.OutputFlag, 0); } env.Start(); // Create empty model GRBModel model = new GRBModel(env); (var grbSeated, var addDecisionVariableTime) = Utils.TimeFunction(() => AddSeatedBinaryVariables(model), "Add Decision Variables"); var addConstraintsTime = Utils.TimeAction(() => AddContraints(model, grbSeated), "Add Constraints"); var addObjectiveTime = Utils.TimeAction(() => AddObjective(model, grbSeated), "Add Objective"); var optimizeTime = Utils.TimeAction(() => model.Optimize(), "Optimizing"); if (tune) { model.Tune(); model.GetTuneResult(0); model.Write(tuneOutputFile); } SeatGroups(grbSeated); // Dispose of model and env model.Dispose(); env.Dispose(); times.Add("Add Decision Variables", addDecisionVariableTime); times.Add("Add Constraints", addConstraintsTime); times.Add("Add Objective", addObjectiveTime); times.Add("Optimizing", optimizeTime); } catch (GRBException e) { Console.WriteLine("Error code: " + e.ErrorCode + ". " + e.Message); throw e; } }, "Total"); times.Add("Total", totalTime); return(times); }