Beispiel #1
0
        protected override async Task <IConstraintSolverResult> Run(ProjectDataSet dataSet, IConstraints constraints, IDictionary <Guid, TimeFrame> overrideActivityTargetDurations)
        {
            if (constraints == null)
            {
                throw new ArgumentNullException("The constraint object cannot be null.");
            }

            var bestSolutionResult = new ConstraintSolverResult(constraints);

            try
            {
                var dataManager = new SolverDataManager(dataSet, bestSolutionResult);

                await dataManager.InitializeDataAsync();

                var solver = new Solver(dataManager);
                await solver.ComputeSolutionAsync();

                bestSolutionResult.State = SolverResultState.OptimalSolutionFound;
            }
            catch (Exception ex)
            {
                bestSolutionResult.Errors.Add(new ConstraintSolverError(null, "Error running GreedySolver solver", ex.LastExceptionMessage()));
            }

            return(bestSolutionResult);
        }
Beispiel #2
0
        public ConstraintSolverResult ScheduleDataSet(ProjectDataSet dataSet, IConstraints constraints, GreedyActivityStrategy strategy)
        {
            var result = new ConstraintSolverResult(constraints);

            try
            {
                var cp = new CriticalPathHelper();
                cp.OrderActivitySchedule(dataSet, result);
                foreach (var a in result.Schedule)
                {
                    _scheduledJobs.GetOrAdd(a.ScheduledItem.UID, a);
                }

                SetupJobsAndResources(dataSet, constraints);
                var dataManager = new SolverDataManager(dataSet, result);
                var solver      = new Solver(dataManager);

                //var results = solver.Solve(
                //    _shifts.Values.ToList(),
                //    _workers.Values.ToList(),
                //    _tools.Values.ToList(),
                //    _zones.Values,
                //    _jobs.Values,
                //    strategy, _shiftManager);

                //foreach (var job in results)
                //{
                //    var activity = _activitiesMap[job.Job.ID];
                //    var scheduledActivity = _scheduledJobs[activity.UID];

                //    var start = TimeFrame.FromMinutes(job.Start);
                //    var end = TimeFrame.FromMinutes(job.End);

                //    scheduledActivity.ScheduledStart = start;
                //    scheduledActivity.ScheduledFinish = end;

                //    //result.ActivitySchedule.AddOrUpdateItemSchedule(job.Start, scheduledActivity);
                //    //result.State = SolverResultState.OptimalSolutionFound;
                //}
                //result.State = SolverResultState.OptimalSolutionFound;
            }
            catch (Exception ex)
            {
                throw new Exception("Yikes! Error in solver!", ex);
            }

            return(result);
        }
Beispiel #3
0
 public Solver(SolverDataManager dataManager)
 {
     _dataManager = dataManager;
 }