Beispiel #1
0
        public void AddConstraints(RoutingData data, RoutingModel model, IntVar cumulTime, RoutingDimension timeDim, int visit)
        {
            var desired = InternalSolver.GetDesired(data, visit);

            if (desired.HasValue)
            {
                // add soft time window for desired
                cumulTime.SetRange(desired.Value.from, desired.Value.to);
            }
            else
            {
                // forbid visit in unavailable
                new UnavailableOnlyStrategy().AddConstraints(data, model, cumulTime, timeDim, visit);
            }
        }
Beispiel #2
0
        public void AddConstraints(RoutingData data, RoutingModel model, IntVar cumulTime, RoutingDimension timeDim, int visit)
        {
            // forbid visit in unavailable
            new UnavailableOnlyStrategy().AddConstraints(data, model, cumulTime, timeDim, visit);

            // add soft time window for desired
            var desired = InternalSolver.GetDesired(data, visit);

            if (desired.HasValue)
            {
                var cost = InternalSolver.GetDesiredCoefficient(data, visit);
                timeDim.SetCumulVarSoftUpperBound(visit, desired.Value.to, cost);
                timeDim.SetCumulVarSoftLowerBound(visit, desired.Value.from, cost);
            }
        }