예제 #1
0
        public SolverResult Solve(SolverConfig solverConfig, Instance instance)
        {
            var parsedSpecializedSolverConfig = JObject
                                                .FromObject(solverConfig.SpecializedSolverConfig)
                                                .ToObject <TSpecializedSolverConfig>(new JsonSerializer {
                DefaultValueHandling = DefaultValueHandling.Populate
            });

            return(this.Solve(solverConfig, parsedSpecializedSolverConfig, instance));
        }
예제 #2
0
        public SolverResult Solve(
            SolverConfig solverConfig,
            TSpecializedSolverConfig specializedSolverConfig,
            Instance instance)
        {
            this.SolverConfig            = solverConfig;
            this.specializedSolverConfig = specializedSolverConfig;

            this.timer = new Timer(this.SolverConfig.TimeLimit);
            this.timer.Restart();

            this.SetInstance(instance);

            this.CheckConfigValidity();
            this.CheckInstanceValidity();

            var        status     = this.Solve();
            StartTimes startTimes = null;

            if (status.IsFeasibleSolution())
            {
                startTimes = this.GetStartTimes();
#if DEBUG
                this.CheckSolution(startTimes);
#endif
            }
            var timeLimitReached = this.SolverReachedTimeLimit();
            var lowerBound       = this.GetLowerBound();
            var objective        = status.IsFeasibleSolution() ? this.GetObjective() : null;
            this.Cleanup();

            this.timer.Stop();
            return(new SolverResult
            {
                Status = status,
                StartTimes = startTimes,
                TimeLimitReached = timeLimitReached,
                RunningTime = TimeSpan.FromMilliseconds(this.timer.ElapsedMilliseconds),
                LowerBound = lowerBound,
                Metadata = this.GetResultMetadata(),
                Objective = objective,
                TimeToBest = status.IsFeasibleSolution() ? this.GetTimeToBest() : null,
                AdditionalInfo = this.GetAdditionalInfo()
            });
        }