コード例 #1
0
        public Tuple <List <double[]>, List <double[]> > FormSchedule(ref InitialValues initVals, Action <string> action = null)
        {
            List <double[]> inFixValues  = AH.CreateListOfArrays(_period, _inDimension, -1.0),
                            outFixValues = AH.CreateListOfArrays(_period, _outDimension, -1.0),
                            inSchedule   = _inAlgorithm.GetSchedule(initVals.inTargets, inFixValues),
                            outSchedule  = _outAlgorithm.GetSchedule(initVals.outTargets, outFixValues);

            DiscreteSchedule reservoirSchedule = GetReservoirSchedule(inSchedule, outSchedule, initVals.startVolume, initVals.pumpsSchedule);
            int idx = reservoirSchedule.FirstIndexOfOutOfRange(initVals.minVolume, initVals.maxVolume);

            if (idx == -1)
            {
                return(new Tuple <List <double[]>, List <double[]> >(inSchedule, outSchedule));
            }

            List <Tuple <List <double[]>, List <double[]> > > schedules;

            switch (initVals.algorithmType)
            {
            case AlgorithmType.GRAPH:
                schedules = GreedyRandomizeSearch(ref initVals, inSchedule, outSchedule, action);
                break;

            default:
                schedules = new List <Tuple <List <double[]>, List <double[]> > >()
                {
                    DinamicProgramming(initVals, action)
                };
                break;
            }

            action("Выбираем оптимальное на основе критериев");

            if (schedules.Count() == 0)
            {
                return(null);
            }
            else if (schedules.Count() == 1)
            {
                return(schedules[0]);
            }
            else
            {
                List <double> criterias = GetCriteria(initVals.inTargets, initVals.outTargets, schedules);
                var           best      = schedules[criterias.IndexOf(criterias.Min())];
                return(best);
            }
        }
コード例 #2
0
            public GreedyNode(List <double[]> inSchedule, List <double[]> outSchedule, ReservoirBalanceAlgorithm algorithm, InitialValues initVals)
            {
                this.inSchedule  = inSchedule;
                this.outSchedule = outSchedule;
                this.initVals    = initVals;
                this.algorithm   = algorithm;

                reservoirSchedule = algorithm.GetReservoirSchedule(inSchedule, outSchedule, initVals.startVolume, initVals.pumpsSchedule);
                crashIndex        = reservoirSchedule.FirstIndexOfOutOfRange(initVals.minVolume, initVals.maxVolume);

                if (crashIndex != -1)
                {
                    sign = reservoirSchedule[crashIndex] > initVals.maxVolume ? -1 : 1;
                }

                IsCalculated   = false;
                IsFullExplored = false;
            }