Ejemplo n.º 1
0
 private void InitCollections(List <TimelinessTimePeriod1> timelinessTimePeriods)
 {
     if (timelinessTimePeriods != null)
     {
         if (timelinessTimePeriods.Count > 0)
         {
             //make the optimization array of uniqueopcomp, feasibleopcomp
             MakeOrderedTOCs(timelinessTimePeriods);
             if (this.TOpComps == null || this.WOpComps == null)
             {
                 this.ErrorMessage = Errors.GetMessage("RESOURCESTOCKS_NOPOWERORNONPOWERINPUTS");
             }
         }
         else
         {
             this.ErrorMessage = Errors.GetMessage("RESOURCESTOCKS_NOPOWERORNONPOWERINPUTS");
         }
     }
     else
     {
         this.ErrorMessage = Errors.GetMessage("RESOURCESTOCKS_NOPOWERORNONPOWERINPUTS");
     }
 }
Ejemplo n.º 2
0
        public void RunOptimization(
            List <TimelinessTimePeriod1> timelinessTimePeriods)
        {
            InitCollections(timelinessTimePeriods);
            if (this.ErrorMessage == string.Empty)
            {
                try
                {
                    //initial collections of TP.OpComps (with each OpComp holding feasible OpComp.TimelinessOpComps)
                    random = new Random(0);
                    // total cost index for problem definition
                    double[][] problemData = MakeProblemData(timelinessTimePeriods);
                    //state represents a solution int array where the first index is the feasibleOpComp
                    //and the second index is the uniqueOpComp
                    //(uniqueOpComp - feasibleOpComp combos that are not possible must have a zero total cost)
                    int[]  state  = RandomState(problemData);
                    double energy = Energy(state, problemData);
                    //best state is the least cost vector of 1 unique opcomp and 1 feasible opcomp
                    int[]  bestState  = state;
                    double bestEnergy = energy;
                    int[]  adjState;
                    double adjEnergy;

                    int iteration = 0;
                    //the higher these are, the longer the algorithm runs
                    //the longer the algo runs the more optimal the solution
                    int    maxIteration = 1000000;
                    double currTemp     = 10000.0;
                    // cooling rate
                    double alpha = 0.995;

                    while (iteration < maxIteration && currTemp > 0.0001)
                    {
                        //adjacent state doesn't allow nonfeasible selections (w,t = 0)
                        adjState  = AdjacentState(state, problemData);
                        adjEnergy = Energy(adjState, problemData);

                        if (adjEnergy < bestEnergy)
                        {
                            bestState  = adjState;
                            bestEnergy = adjEnergy;
                        }
                        // [0, 1.0)
                        double p = random.NextDouble();
                        if (AcceptanceProb(energy, adjEnergy, currTemp) > p)
                        {
                            state  = adjState;
                            energy = adjEnergy;
                        }
                        // cool down; annealing schedule
                        currTemp = currTemp * alpha;
                        ++iteration;
                    }
                    //temperature has cooled to (almost) zero at final iteration
                    MakeBestMachineryCombos(timelinessTimePeriods, bestState, problemData);
                }
                catch (Exception ex)
                {
                    this.ErrorMessage = string.Concat(Errors.GetMessage("RESOURCESTOCKS_NOSIMULATEDANNEALING"),
                                                      ex.ToString());
                }
            }
        }
Ejemplo n.º 3
0
        public void RunOptimization(
            TimelinessOpComp1 initialTimelinessOCStock, List <Machinery1Input> machineryInputs)
        {
            BestMachineryCombos = new Dictionary <Machinery1Input, Machinery1Input>();
            try
            {
                random            = new Random(0);
                this.ErrorMessage = string.Empty;

                this.PowerInputs    = machineryInputs.FindAll(m => m.FuelCost > 0);
                this.NonPowerInputs = machineryInputs.FindAll(m => m.FuelCost <= 0);
                if (this.PowerInputs.Count > 0 && this.NonPowerInputs.Count > 0)
                {
                    // total cost index for problem definition
                    double[][] problemData = MakeProblemData(initialTimelinessOCStock);
                    //state represents a solution int array where the index is the nonpowerimplement and the value is the powerimplement
                    //(powerinput - implement combos that are not possible must have a zero total cost)
                    int[]  state  = RandomState(problemData);
                    double energy = Energy(state, problemData);
                    //best state is the least cost vector of 1 power input and 1 non power inputs
                    int[]  bestState  = state;
                    double bestEnergy = energy;
                    int[]  adjState;
                    double adjEnergy;

                    int iteration = 0;
                    //the higher these are, the longer the algorithm runs
                    //the longer the algo runs the more optimal the solution
                    int    maxIteration = 1000000;
                    double currTemp     = 10000.0;
                    // cooling rate
                    double alpha = 0.995;

                    while (iteration < maxIteration && currTemp > 0.0001)
                    {
                        adjState  = AdjacentState(state, problemData);
                        adjEnergy = Energy(adjState, problemData);

                        if (adjEnergy < bestEnergy)
                        {
                            bestState  = adjState;
                            bestEnergy = adjEnergy;
                        }
                        // [0, 1.0)
                        double p = random.NextDouble();
                        if (AcceptanceProb(energy, adjEnergy, currTemp) > p)
                        {
                            state  = adjState;
                            energy = adjEnergy;
                        }
                        // cool down; annealing schedule
                        currTemp = currTemp * alpha;
                        ++iteration;
                    }
                    //temperature has cooled to (almost) zero at final iteration
                    MakeBestMachineryCombos(bestState, problemData);
                }
                else
                {
                    this.ErrorMessage = Errors.GetMessage("RESOURCESTOCKS_NOPOWERORNONPOWERINPUTS");
                }
            }
            catch (Exception ex)
            {
                this.ErrorMessage = string.Concat(Errors.GetMessage("RESOURCESTOCKS_NOSIMULATEDANNEALING"),
                                                  ex.ToString());
            }
        }
Ejemplo n.º 4
0
        public async Task <bool> SetObservedMathResult(string mathType, string distType,
                                                       string mathSubType, double mostLikely, double[] obsTs)
        {
            bool bHasSet = false;
            //this is observed data rather than randomly sampled data
            StringBuilder sb = new StringBuilder();

            if (obsTs.Count() > 0)
            {
                //xy array of 10 points on cdf
                //var array = qTs.ToArray();
                Array.Sort(obsTs);
                int i00  = 0;
                int i10  = (int)(obsTs.Length * .10);
                int i20  = (int)(obsTs.Length * .20);
                int i30  = (int)(obsTs.Length * .30);
                int i40  = (int)(obsTs.Length * .40);
                int i50  = (int)(obsTs.Length * .50);
                int i60  = (int)(obsTs.Length * .60);
                int i70  = (int)(obsTs.Length * .70);
                int i80  = (int)(obsTs.Length * .80);
                int i90  = (int)(obsTs.Length * .90);
                int i100 = (int)(obsTs.Length - 1);
                sb.AppendLine(Errors.GetMessage("STATS_DESC5"));
                sb.AppendLine(string.Concat(
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i00]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i10]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i20]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i30]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i40]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i50]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i60]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i70]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i80]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i90]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(obsTs, obsTs[i100]).ToString("N2", CultureInfo.InvariantCulture)));
                sb.AppendLine(string.Concat(
                                  obsTs[i00].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i10].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i20].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i30].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i40].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i50].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i60].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i70].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i80].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i90].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  obsTs[i100].ToString("F4", CultureInfo.InvariantCulture)));
                sb.AppendLine(Errors.GetMessage("STATS_DESC3"));
                sb.AppendLine(Errors.GetMessage("STATS_DESC2"));
                //qT is the result of math and stored in sixth col
                var stats = new MathNet.Numerics.Statistics.DescriptiveStatistics(obsTs);
                sb.AppendLine(string.Concat(stats.Count.ToString(), Constants.CSV_DELIMITER, obsTs.Sum().ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                            stats.Mean.ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                            MathNet.Numerics.Statistics.Statistics.Median(obsTs).ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                            stats.StandardDeviation.ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER, stats.Variance.ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                            stats.Minimum.ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER, stats.Maximum.ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER));
                string sLowerCI = string.Concat(Errors.GetMessage("LOWER"), this.CILevel.ToString(), Errors.GetMessage("CI_PCT"));
                string sUpperCI = string.Concat(Errors.GetMessage("UPPER"), this.CILevel.ToString(), Errors.GetMessage("CI_PCT"));
                this.IndicatorQT.QTM     = stats.Mean;
                this.IndicatorQT.QTL     = stats.Mean - CalculatorHelpers.GetConfidenceInterval(this.CILevel, stats.Count, stats.StandardDeviation);
                this.IndicatorQT.QTU     = stats.Mean + CalculatorHelpers.GetConfidenceInterval(this.CILevel, stats.Count, stats.StandardDeviation);
                this.IndicatorQT.QTLUnit = sLowerCI;
                this.IndicatorQT.QTUUnit = sUpperCI;
            }
            else
            {
                sb.AppendLine(Errors.MakeStandardErrorMsg("DATAURL_BADDATA"));
            }
            if (this.IndicatorQT.MathResult.ToLower().StartsWith("http"))
            {
                bool bHasSaved = await CalculatorHelpers.SaveTextInURI(
                    Params.ExtensionDocToCalcURI, sb.ToString(), this.IndicatorQT.MathResult);

                if (!string.IsNullOrEmpty(Params.ExtensionDocToCalcURI.ErrorMessage))
                {
                    this.IndicatorQT.MathResult += Params.ExtensionDocToCalcURI.ErrorMessage;
                    //done with errormsg
                    Params.ExtensionDocToCalcURI.ErrorMessage = string.Empty;
                }
            }
            else
            {
                this.IndicatorQT.MathResult = sb.ToString();
            }
            bHasSet = true;
            return(bHasSet);
        }
Ejemplo n.º 5
0
        public async Task <bool> SetRange(double mostLikelyEstimate, double lowEstimate, double highEstimate,
                                          double[] data, List <double> cdf = null)
        {
            bool          bHasSet = false;
            StringBuilder sb      = new StringBuilder();

            if (data == null)
            {
                sb.AppendLine("This indicator does not have the properties needed for descriptive statistics.");
            }
            if (data.Count() == 0)
            {
                sb.AppendLine("This indicator does not have the properties needed for descriptive statistics.");
            }
            //default has no range of values
            double lowRange       = lowEstimate;
            double highRange      = highEstimate;
            double mostLikely     = mostLikelyEstimate;
            string mostLikelyUnit = string.Empty;
            string lowUnit        = string.Empty;
            string highUnit       = string.Empty;
            bool   bNeedsCDF      = false;
            var    stats          = new MathNet.Numerics.Statistics.DescriptiveStatistics(data);
            string sLowerCI       = string.Concat(Errors.GetMessage("LOWER"), this.CILevel.ToString(), Errors.GetMessage("CI_PCT"));
            string sUpperCI       = string.Concat(Errors.GetMessage("UPPER"), this.CILevel.ToString(), Errors.GetMessage("CI_PCT"));

            //some data has all zeros and does not use sampled data
            if (stats.Mean != 0)
            {
                mostLikely     = stats.Mean;
                mostLikelyUnit = "mean";
                lowRange       = mostLikely - CalculatorHelpers.GetConfidenceInterval(this.CILevel, stats.Count, stats.StandardDeviation);
                lowUnit        = sLowerCI;
                highRange      = mostLikely + CalculatorHelpers.GetConfidenceInterval(this.CILevel, stats.Count, stats.StandardDeviation);
                highUnit       = sUpperCI;
                bNeedsCDF      = true;
            }

            if (bNeedsCDF)
            {
                //csv strings use f4 not n4
                sb.AppendLine(Errors.GetMessage("STATS_DESC1"));
                sb.AppendLine(Errors.GetMessage("STATS_DESC2"));
                sb.AppendLine(string.Concat(stats.Count.ToString(), ", ", data.Sum().ToString("F4", CultureInfo.InvariantCulture), ", ",
                                            stats.Mean.ToString("F4", CultureInfo.InvariantCulture), ", ",
                                            MathNet.Numerics.Statistics.Statistics.Median(data).ToString("F4", CultureInfo.InvariantCulture), ", ",
                                            stats.StandardDeviation.ToString("F4", CultureInfo.InvariantCulture), ", ", stats.Variance.ToString("F4", CultureInfo.InvariantCulture), ", ",
                                            stats.Minimum.ToString("F4", CultureInfo.InvariantCulture), ", ", stats.Maximum.ToString("F4", CultureInfo.InvariantCulture), ", "));
                //xy array of 10 points on cdf
                var array = data.ToArray();
                Array.Sort(array);
                int i00  = 0;
                int i10  = (int)(array.Length * .10);
                int i20  = (int)(array.Length * .20);
                int i30  = (int)(array.Length * .30);
                int i40  = (int)(array.Length * .40);
                int i50  = (int)(array.Length * .50);
                int i60  = (int)(array.Length * .60);
                int i70  = (int)(array.Length * .70);
                int i80  = (int)(array.Length * .80);
                int i90  = (int)(array.Length * .90);
                int i100 = (int)(array.Length - 1);
                sb.AppendLine(Errors.GetMessage("STATS_DESC4"));
                sb.AppendLine(string.Concat(
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i00]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i10]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i20]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i30]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i40]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i50]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i60]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i70]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i80]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i90]).ToString("N2", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  MathNet.Numerics.Statistics.Statistics.EmpiricalCDF(data, array[i100]).ToString("N2", CultureInfo.InvariantCulture)));
                sb.AppendLine(string.Concat(
                                  array[i00].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i10].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i20].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i30].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i40].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i50].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i60].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i70].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i80].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i90].ToString("F4", CultureInfo.InvariantCulture), Constants.CSV_DELIMITER,
                                  array[i100].ToString("F4", CultureInfo.InvariantCulture)));
                if (cdf == null)
                {
                    cdf = new List <double>();
                }
                cdf.Add(array[i00]);
                cdf.Add(array[i10]);
                cdf.Add(array[i20]);
                cdf.Add(array[i30]);
                cdf.Add(array[i40]);
                cdf.Add(array[i50]);
                cdf.Add(array[i60]);
                cdf.Add(array[i70]);
                cdf.Add(array[i80]);
                cdf.Add(array[i90]);
                cdf.Add(array[i100]);
            }
            else
            {
                sb.AppendLine(Errors.GetMessage("STATS_DESC6"));
            }
            //doubles need restricted digits
            mostLikely = Math.Round(mostLikely, 4);
            lowRange   = Math.Round(lowRange, 4);
            highRange  = Math.Round(highRange, 4);
            string sD1Unit = "low";
            string sD2Unit = "high";

            this.IndicatorQT.QTD1 = lowEstimate;
            if (this.IndicatorQT.QTD1Unit == string.Empty || this.IndicatorQT.QTD1Unit == Constants.NONE)
            {
                this.IndicatorQT.QTD1Unit = sD1Unit;
            }
            this.IndicatorQT.QTD2 = highEstimate;
            if (this.IndicatorQT.QTD2Unit == string.Empty || this.IndicatorQT.QTD2Unit == Constants.NONE)
            {
                this.IndicatorQT.QTD2Unit = sD2Unit;
            }
            //computed results
            this.IndicatorQT.QTM = mostLikely;
            if (this.IndicatorQT.QTMUnit == string.Empty || this.IndicatorQT.QTMUnit == Constants.NONE)
            {
                this.IndicatorQT.QTMUnit = mostLikelyUnit;
            }
            this.IndicatorQT.QTL = lowRange;
            if (this.IndicatorQT.QTLUnit == string.Empty || this.IndicatorQT.QTLUnit == Constants.NONE)
            {
                this.IndicatorQT.QTLUnit = lowUnit;
            }
            this.IndicatorQT.QTU = highRange;
            if (this.IndicatorQT.QTUUnit == string.Empty || this.IndicatorQT.QTUUnit == Constants.NONE)
            {
                this.IndicatorQT.QTUUnit = highUnit;
            }
            if (this.IndicatorQT.MathResult.ToLower().StartsWith("http"))
            {
                bool bHasSaved = await CalculatorHelpers.SaveTextInURI(
                    Params.ExtensionDocToCalcURI, sb.ToString(), this.IndicatorQT.MathResult);

                if (!string.IsNullOrEmpty(Params.ExtensionDocToCalcURI.ErrorMessage))
                {
                    this.IndicatorQT.MathResult += Params.ExtensionDocToCalcURI.ErrorMessage;
                    //done with errormsg
                    Params.ExtensionDocToCalcURI.ErrorMessage = string.Empty;
                }
            }
            else
            {
                this.IndicatorQT.MathResult = sb.ToString();
            }
            bHasSet = true;
            return(bHasSet);
        }
Ejemplo n.º 6
0
        public void RunOptimization(List <TimelinessTimePeriod1> timelinessTimePeriods)
        {
            //prepare the initial, ordered collections of opcomps
            InitCollections(timelinessTimePeriods);
            if (this.ErrorMessage == string.Empty)
            {
                try
                {
                    //state holds feasible opcomps for each uniqueopcomp
                    //[1][4][20][15][10][7] = means the first unique opcomp
                    //uses the feasible opcomp with an index of 1
                    //= this.InitialOpComps[0].FeasibleOpComps[1]
                    int u = 0;
                    int f = 0;

                    //init this.CurrentStateOpComps total costs properties
                    double totalCurrentStateCost = SetTotalCostsForCurrentState();
                    //init this.BestOpComps total costs properties
                    SetBestState();
                    double totalBestStateCost = SetTotalCostsForBestState();
                    //all feasible combinations are looped through
                    //each time a new feasible is checked, a new timeliness cost
                    //is added to it when its date must be changed
                    //best state is least cost for the current full array
                    u = 0;
                    bool bHasNewFixedUniqueOpComp = false;
                    foreach (var uniqueOpComp in this.InitialOpComps)
                    {
                        if (uniqueOpComp.TimelinessOpComps != null)
                        {
                            f = 0;
                            foreach (var feasibleOpComp in uniqueOpComp.TimelinessOpComps)
                            {
                                //add feasibleopcomp to currentopcomps
                                totalCurrentStateCost = SetTotalCostsForCurrentState(u, f);
                                totalBestStateCost    = SetTotalCostsForBestState();
                                if (totalCurrentStateCost < totalBestStateCost && totalCurrentStateCost > 0)
                                {
                                    //new least cost combination
                                    //copy this.CurrentStateOpComps to this.BestOpComps
                                    SetBestState();
                                    bHasNewFixedUniqueOpComp = true;
                                }
                                if (bHasNewFixedUniqueOpComp)
                                {
                                    //every time the best state is changed
                                    //recheck all combos, keeping the new feasibleOpComp fixed
                                    ChangeBestStateUsingFixedUniqueOpComp(u);
                                }
                                bHasNewFixedUniqueOpComp = false;
                                f++;
                            }
                        }
                        u++;
                    }
                    //set the solution collection
                    MakeBestMachineryCombos(timelinessTimePeriods);
                }
                catch (Exception ex)
                {
                    this.ErrorMessage = string.Concat(Errors.GetMessage("RESOURCESTOCKS_NOMACH1SELECTSCHEDULE"),
                                                      ex.ToString());
                }
            }
        }