private Tuple <bool, bool> preCheckConfigReqOne(Configuration config)
        {
            bool hasAllConfigs = true;
            bool hasAtLeastOne = false;

            foreach (BinaryOption bo in leftHandSide.participatingBoolOptions.Union(rightHandSide.participatingBoolOptions))
            {
                if (!config.BinaryOptions.ContainsKey(bo))
                {
                    hasAllConfigs = false;
                }
                else if (config.BinaryOptions.ContainsKey(bo))
                {
                    hasAtLeastOne = true;
                }
            }

            foreach (NumericOption no in leftHandSide.participatingNumOptions.Union(rightHandSide.participatingNumOptions))
            {
                InfluenceFunction func = new InfluenceFunction(no.ToString(), GlobalState.varModel);
                if (!config.NumericOptions.ContainsKey(no))
                {
                    hasAllConfigs = false;
                }
                else if (func.eval(config) == 0)
                {
                    hasAllConfigs = false;
                }
                else if (config.NumericOptions.ContainsKey(no))
                {
                    hasAtLeastOne = true;
                }
            }
            return(Tuple.Create(hasAllConfigs, hasAtLeastOne));
        }
        /// <summary>
        /// Computes the next value of the numeric option using the step function
        /// </summary>
        /// <param name="value">Value from which the next value shall be computed</param>
        /// <returns>The next valid value within the value range of that option</returns>
        public double getNextValue(double value)
        {
            Dictionary <NumericOption, double> t = new Dictionary <NumericOption, double>();

            t.Add(this, value);
            return(Math.Round(stepFunction.eval(t), 3));
        }
Exemple #3
0
 /// <summary>
 /// Computes the next value of the numeric option using the step function
 /// </summary>
 /// <param name="value">Value from which the next value shall be computed</param>
 /// <returns>The next valid value within the value range of that option</returns>
 public double getNextValue(double value)
 {
     if (stepFunction != null)
     {
         Dictionary <NumericOption, double> t = new Dictionary <NumericOption, double>();
         t.Add(this, value);
         return(Math.Round(stepFunction.eval(t), 3));
     }
     else
     {
         double nextGreaterValue = -1;
         for (int i = 0; i < values.Count(); i++)
         {
             if (values.Values[i] > value && (Math.Abs(value - values.Values[i]) < Math.Abs(nextGreaterValue - values.Values[i])))
             {
                 nextGreaterValue = values.Values[i];
             }
         }
         return(nextGreaterValue);
     }
 }
Exemple #4
0
        /// <summary>
        /// Tests whether a configuration holds for the given non-boolean constraint.
        /// </summary>
        /// <param name="config">The configuration of interest.</param>
        /// <returns>True is the configuration holds for the constraint.</returns>
        public bool configIsValid(Configuration config)
        {
            if (!configHasOptionsOfConstraint(config))
            {
                return(true);
            }


            double left  = leftHandSide.eval(config);
            double right = rightHandSide.eval(config);

            switch (comparator)
            {
            case ">=":
            {
                if (left >= right)
                {
                    return(true);
                }
                break;
            }

            case "<=":
            {
                if (left <= right)
                {
                    return(true);
                }
                break;
            }

            case "=":
            {
                if (left == right)
                {
                    return(true);
                }
                break;
            }

            case ">":
            {
                if (left > right)
                {
                    return(true);
                }
                break;
            }

            case "<":
            {
                if (left < right)
                {
                    return(true);
                }
                break;
            }
            }

            return(false);
        }