Ejemplo n.º 1
0
        public Solution RunUnavailbility()
        {
            var stopwatch = Stopwatch.StartNew();

            var model = new CCTModel(data, formulation, MIPmodelParameters);

            model.Optimize(TimelimitStageI - Timetotighten);
            Console.WriteLine($"Unavailableused: {model.GetUnavailableused()} ({(double) model.GetUnavailableused()/data.Courses.Sum(c => c.Lectures):0.00%})");

            model.PenalizeUnavailability(10);

            // model.SetObjective(0, 0, 0.01);
            // model.SetObjective(0, 0, 0);
            //model.SetMipHintToCurrent();
            model.SetProximityOrigin();
            // model.SetQualConstraint(model.ObjSoftCons);

            model.Fixsol(true);
            model.Optimize();
            model.Fixsol(false);

            //    model.Optimize(timetotighten+50,cutoff:500);
            //     model.ModelParameters.AbortSolverOnZeroPenalty = true;
            var tighttimer = Stopwatch.StartNew();

            model.Optimize(Timetotighten + 900);
            tighttimer.Stop();
            model.DisplayObjectives();
            _solution = new Solution(data, formulation);
            _solution.SetAssignments(model.GetAssignments());

            Console.WriteLine($"Unavailableused: {model.GetUnavailableused()} ({(double)model.GetUnavailableused() / data.Courses.Sum(c => c.Lectures):0.00%})");

            //timers
            stopwatch.Stop();
            tighttimer.Stop();
            totalseconds     = (int)stopwatch.Elapsed.TotalSeconds;
            roomtightseconds = (int)tighttimer.Elapsed.TotalSeconds;

            return(_solution);
        }