Esempio 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);
        }
Esempio n. 2
0
        public Solution RunLargeCoursesFirst()
        {
            var stopwatch = Stopwatch.StartNew();

            var cutlimit   = 0.1;
            var ncourses   = 10;//(int) 0.1*data.Courses.Count;
            var newcourses = data.Courses.OrderByDescending(c => c.NumberOfStudents).Take(ncourses).ToList();
            var remcourse  = data.Courses.Except(newcourses).ToList();

            var newdata = new Data(data.Courses, data.Lecturers, data.Rooms, data.Curricula, data.TimeSlots, data.Days, data.Periods, data.MinimumPeriodsPerDay, data.MaximumPeriodsPerDay);

            newdata.CleanRemovedCourses(remcourse);

            Console.WriteLine($"Solving with {newcourses.Count} ({(double) newcourses.Count/data.Courses.Count : 0.00%})");
            var modelpre = new CCTModel(newdata, formulation, MIPmodelParameters);

            modelpre.Optimize();
            var ass = modelpre.GetAssignments();

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

            // model.SetAndFixSolution(ass);

            model.Optimize();

            //    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);
        }