Пример #1
0
        private EquationType ifCarry(int first, int second, EquationMethod method)
        {
            int first10      = first / 10;
            int firstSingle  = first % 10;
            int second10     = second / 10;
            int secondSingle = second % 10;

            EquationType retval = EquationType.NonCarry;

            if (method == EquationMethod.Add)
            {
                if (first10 + second10 >= 10 ||
                    firstSingle + secondSingle >= 10)
                {
                    retval = EquationType.Carry;
                }
            }
            else if (method == EquationMethod.Subtract)
            {
                if (first10 - second10 < 0 ||
                    firstSingle - secondSingle < 0)
                {
                    retval = EquationType.Carry;
                }
            }

            return(retval);
        }
Пример #2
0
 public PolyEquation(double x2, double x1, double x0)
 {
     this._x0     = x0;
     this._x1     = x1;
     this._x2     = x2;
     this._eqType = EquationType.SecondDegree;
 }
Пример #3
0
        public Equation(string equation, char usedVariable)
        {
            variable = usedVariable;
            string[] EquationElements = equation.Split(' ');
            var      EquationPatterns = new Dictionary <Regex, EquationType>
            {
                { new Regex(@"\d*\w ([\+|-] \d+ )?= 0"), EquationType.Linear },
                { new Regex(@"((\d*\|\w\||\|\d*\w\|) ([\+|-] \d+)?|\|\d*\w [\+|-] \d+\|) = 0"), EquationType.Modulus },
                { new Regex(@"√\w"), EquationType.Root },
                { new Regex(@"\d*\w\^2 ([\+|-] \d*\w )?([\+|-] \d+ )?= 0"), EquationType.Parabola }
            };                                                          //ДОДЕЛАТЬ

            foreach (var pattern in EquationPatterns.Keys)
            {
                if (pattern.IsMatch(equation))
                {
                    type = EquationPatterns[pattern];
                    break;
                }
            }

            switch (type)
            {
            case EquationType.Linear:
                LinearEquationDecomposition(EquationElements);
                break;

            case EquationType.Parabola:
                //Метод
                break;
            }
        }
Пример #4
0
        public void GenEquation(ref String _equation, ref int _answer,
                                EquationType type)
        {
            int first  = 0;
            int second = 0;
            int third  = 0;

            EquationMethod method1 = EquationMethod.Null;
            EquationMethod method2 = EquationMethod.Null;

            //decide 3 units or 4 units
            if (getRandomBool())//3 units
            {
                get3Units(ref first, ref second, ref third, ref method1, ref method2, type);
            }
            else//4 units
            {
                get4Units(ref first, ref second, ref third, ref method1, ref method2, type);
            }

            _equation = first.ToString() +
                        Method2String(method1) + second.ToString() +
                        Method2String(method2) + third + " =";

            _answer = doCalc(doCalc(first, second, method1), third, method2);
        }
Пример #5
0
 public object[] GetPositiveTestValues(EquationType equationType)
 {
     if (SelectedGender == null)
     {
         return(new object[0]);
     }
     return(new object[] { SelectedGender });
 }
Пример #6
0
        public static Storyboard CreateAnim(DependencyObject target, EquationType type, TimeSpan duration, PropertyPath property, double from, double to)
        {
            Storyboard sb = new Storyboard();

            AddAnimation(sb, target, property, duration, type, from, to);

            return sb;
        }
Пример #7
0
        public virtual object[] GetPositiveTestValues(EquationType equationType)
        {
            if (Value == null)
            {
                return(new object[0]);
            }

            return(new object[] { equationType.GetPositiveTestValue(Value.Value, Incrementer, Decrementer) });
        }
Пример #8
0
        public object GetNegativeTestValue(EquationType equationType, IEnumerable <object> positiveValues)
        {
            if (Value == null)
            {
                return(null);
            }

            return(!Value.Value);
        }
Пример #9
0
 /// <summary>
 /// DiagramEquation Class Constructor
 /// </summary>
 /// <param name="equation"></param>
 /// <param name="equationType"></param>
 /// <param name="n"></param>
 /// <param name="x0"></param>
 public DiagramEquation(string equation, EquationType equationType, int n = 1, int x0 = 0)
 {
     EquationString = equation.Replace(" ", string.Empty);
     EquationType   = equationType;
     N      = n;
     X0     = x0;
     Points = new List <Point>();
     DrawDiagram();
 }
Пример #10
0
        public object[] GetPositiveTestValues(EquationType equationType)
        {
            if (Value == null)
            {
                return(new object[0]);
            }

            return(new object[] { Value.Value });
        }
Пример #11
0
        public object GetNegativeTestValue(EquationType equationType, IEnumerable <object> positiveValues)
        {
            if (SelectedGender == null)
            {
                return(null);
            }

            return(Gender.All.FirstOrDefault(g => g.Id != SelectedGender.Id));
        }
Пример #12
0
        /// <name>
        /// MathEquation
        /// </name>
        /// <summary>
        /// Initializes a new instance of the MathEquation class.
        /// </summary>
        /// <param name="level">Level of equation difficulty. Can be > 1 if user has saved data</param>
        /// <param name="increaseRange">how much each level increases by</param>
        /// <param name="type">type of equation</param>
        /// <author>
        /// Sabrina Hemming
        /// </author>
        /// <date>
        /// 3/2/18
        /// </date>
        public MathEquation(int increaseRange, int level, EquationType type)
        {
            this.equationType  = type;
            Level              = level;
            this.increaseRange = increaseRange;

            // randomly generate 2 numbers for the math problem
            rnd = new System.Random();
            GenerateNewEquation();
        }
Пример #13
0
 /// <summary>
 /// Diagram Class Constructor
 /// </summary>
 /// <param name="parentGrid"></param>
 /// <param name="equation"></param>
 /// <param name="equationType"></param>
 /// <param name="n"></param>
 /// <param name="x0"></param>
 /// <param name="sinusDiagram"></param>
 public Diagram(Grid parentGrid, string equation, EquationType equationType,
                int n = 1, int x0 = 0, Polyline sinusDiagram = null)
 {
     ParentGrid   = parentGrid;
     EquationType = equationType;
     Equation     = new DiagramEquation(equation, equationType, n, x0);
     SinusDiagram = sinusDiagram;
     DrawLines();
     DrawAxises();
     DrawDiagram();
 }
        public void InitWithDefaultValues()
        {
            this.CurveEquations = new List <string>();
            this.PointEquations = new List <XyPoint <string> >();

            this.SelectedEquationIndex = 0;
            this.SelectedEquationType  = EquationType.Curve;

            this.ParamInfoList = CreateDefaultPresetParamInfoList();

            this.CurveEquations.Add(DEFAULT_EQUATION);
        }
Пример #15
0
 private dynamic valueMaker(EquationType type, dynamic maxValue, dynamic minValue)
 {
     if (type == EquationType.Int)
     {
         int val = RandomGenerator.Instance.Random.Next((int)minValue, (int)maxValue + 1);
         return(val);
     }
     else
     {
         double val = RandomGenerator.Instance.Random.NextDouble() * (maxValue - minValue) + minValue;
         return(val);
     }
 }
Пример #16
0
 public static String GetString(EquationType type)
 {
     switch (type) {
     default:
         return "+";
     case EquationType.SUBTRACTION:
         return "-";
     case EquationType.MULTIPLICATION:
         return "x";
     case EquationType.DIVISISON:
         return "/";
     }
 }
Пример #17
0
        private void fillOut(Dictionary <char, dynamic> inputs, dynamic output, dynamic acceptableCost, dynamic mutationRate, int populationSize, EquationType type, dynamic maxValue, dynamic minValue)
        {
            this.inputs         = inputs;
            this.output         = output;
            this.acceptableCost = acceptableCost;
            this.mutationRate   = mutationRate;
            this.populationSize = populationSize;
            this.type           = type;
            this.maxValue       = maxValue;
            this.minValue       = minValue;

            this.Equations = new List <EF_Equation>();
        }
Пример #18
0
        public static Storyboard CreateAnim(DependencyObject target, EquationType type, TimeSpan duration, params TweenParameter[] parameters)
        {
            Storyboard sb = new Storyboard();

            foreach (var p in parameters)
            {
                AddAnimation(sb, target, p.Property
                    , p.Duration.HasValue ? p.Duration.Value : duration
                    , p.Type.HasValue ? p.Type.Value : type
                    , p.From, p.To);
            }

            return sb;
        }
Пример #19
0
        public object GetNegativeTestValue(EquationType equationType, IEnumerable <object> positiveValues)
        {
            var itemsToExclude = new List <object>();

            itemsToExclude.AddRange(positiveValues);

            var itemsToChoseFrom = Items.Where(item => !itemsToExclude.Contains(item.OriginalItem)).ToArray();

            if (itemsToChoseFrom.Length == 0)
            {
                return(null);
            }

            return(itemsToChoseFrom.First().OriginalItem);
        }
Пример #20
0
        public static String GetString(EquationType type)
        {
            switch (type)
            {
            default:
                return("+");

            case EquationType.SUBTRACTION:
                return("-");

            case EquationType.MULTIPLICATION:
                return("x");

            case EquationType.DIVISISON:
                return("/");
            }
        }
Пример #21
0
        public static DoubleAnimationUsingKeyFrames AddAnimation(Storyboard sb, DependencyObject target, PropertyPath property, TimeSpan duration, EquationType type, double from, double to)
        {
            DoubleAnimationUsingKeyFrames anim = new DoubleAnimationUsingKeyFrames();
            sb.Children.Add(anim);

            Storyboard.SetTarget(anim, target);
            Storyboard.SetTargetProperty(anim, property);

            anim.Duration = new Duration(duration);

            Tween.SetFrom(anim, from);
            Tween.SetTo(anim, to);
            Tween.SetType(anim, type);

            Tween.SetIsInitialize(anim, true);

            return anim;
        }
Пример #22
0
        private void get3Units(ref int first, ref int second, ref int third,
                               ref EquationMethod method1, ref EquationMethod method2,
                               EquationType type)
        {
            int carryCount = 0;

            while (true)
            {
                carryCount = 0;
                first      = get1DigitNum();
                second     = get1DigitNum();
                third      = get1DigitNum();
                method1    = getRandomMethod();
                method2    = getRandomMethod();

                if (ifCarry(first, second, method1) == EquationType.Carry)
                {
                    carryCount++;
                }

                int firstAndSecond = doCalc(first, second, method1);

                if (ifCarry(firstAndSecond, third, method2) == EquationType.Carry)
                {
                    carryCount++;
                }

                if (type == EquationType.Carry)
                {
                    if (carryCount == 1 && doCalc(firstAndSecond, third, method2) >= 0)
                    {
                        break;
                    }
                }
                else if (type == EquationType.NonCarry && doCalc(firstAndSecond, third, method2) >= 0)
                {
                    if (carryCount == 0)
                    {
                        break;
                    }
                }
            }
        }
Пример #23
0
        private EF_Variable variableMaker(char c, dynamic value, EquationType type, dynamic maxValue, dynamic minValue)
        {
            dynamic      coeff = valueMaker(type, maxValue, minValue);
            dynamic      power = valueMaker(type, maxValue, minValue);
            VariableType varType;

            if (type == EquationType.Int)
            {
                varType = VariableType.Int;
            }
            else
            {
                varType = VariableType.Double;
            }

            EF_Variable vari = new EF_Variable(c, value, coeff, power, varType);

            return(vari);
        }
Пример #24
0
        public EF_Equation MakeEquation(Dictionary <char, dynamic> inputs, EquationType type, dynamic maxValue, dynamic minValue)
        {
            List <EF_Variable> vars     = new List <EF_Variable>();
            List <EF_Operator> operands = new List <EF_Operator>();
            int i = 0;

            foreach (KeyValuePair <char, dynamic> input in inputs)
            {
                vars.Add(variableMaker(input.Key, input.Value, type, maxValue, minValue));
                if (i < inputs.Count - 1)
                {
                    operands.Add(operatorMaker());
                }

                i++;
            }

            return(new EF_Equation(type, vars, operands));
        }
Пример #25
0
        public virtual object GetNegativeTestValue(EquationType equationType, IEnumerable <object> positiveValues)
        {
            if (Value == null)
            {
                return(null);
            }

            int currentTry = 0;

            TValue negativeValue = Value.Value;

            do
            {
                negativeValue = equationType.GetNegativeTestValue(negativeValue, Incrementer, Decrementer);
                currentTry++;
            }while (positiveValues.Contains(negativeValue) && currentTry < 1000);

            return(negativeValue);
        }
Пример #26
0
    /// <summary>
    /// 计算方程式的解
    ///
    /// 这个函数是希望外部调用的接口
    /// 因为现在最多支持到一元三次函数, 所以只需要4个参数
    /// 不同的函数类型, 参数有不同的解释
    /// <see cref="EquationType"/>
    /// </summary>
    /// <param name="type"></param>
    /// <param name="x"></param>
    /// <param name="param3"></param>
    /// <param name="param2"></param>
    /// <param name="param1"></param>
    /// <param name="param0"></param>
    /// <returns></returns>
    public static float CalculateInverseEquation(EquationType type, float x, float param3, float param2, float param1, float param0)
    {
        switch (type)
        {
        case EquationType.Cubical:
            return(RootOfCubicalEquation(x, param3, param2, param1, param0));

        case EquationType.Quadratic:
            return(RootOfQuadraticEquation(x, param2, param1, param0));

        case EquationType.Linear:
            return(RootOfLinearEquation(x, param1, param0));

        case EquationType.Power:
            return(RootOfPowerEquation(x, param1, param0));

        default:
            return(0);
        }
    }
Пример #27
0
        public string Solve()
        {
            double delta = _x1 * _x1 - 4 * _x2 * _x0;
            string solution;

            if ((_x2 == 0) && (_x1 == 0) && (_x0 == 0))
            {
                throw new PolyException("O infinitate de solutii", _x2, _x1, _x0);
            }
            else if ((_x2 == 0) && (_x1 == 0) && (_x0 != 0))
            {
                throw new PolyException("Nicio solutie", _x2, _x1, _x0);
            }

            if (_x2 == 0)
            {
                _eqType  = EquationType.FirstDegree;
                solution = (-_x0 / _x1).ToString();
            }
            else if (delta > 0)
            {
                double sqrtDelta = Math.Sqrt(delta);
                double sol1      = (-_x1 + sqrtDelta) / (2.0 * _x2);
                double sol2      = (-_x1 - sqrtDelta) / (2.0 * _x2);

                solution = "x1 = " + sol1.ToString() + "; x2 = " + sol2.ToString();
            }
            else
            {
                double rsol = -_x1 / (2.0 * _x2);
                double isol = Math.Sqrt(-delta) / (2.0 * _x2);

                solution  = "x1 = " + rsol + " + " + isol + "i";
                solution += "; x2 = " + rsol + " - " + isol + "i";
            }

            return(solution);
        }
Пример #28
0
    /// <summary>
    /// Generic Easing equation function
    /// </summary>
    /// <param name="t">Current time in seconds.</param>
    /// <param name="b">Starting value.</param>
    /// <param name="c">Final value.</param>
    /// <param name="d">Duration of animation.</param>
    /// <returns>The correct value.</returns>
    public static double GetValue(EquationType type, double t, double b, double c, double d)
    {
        double val = 0.0;

        if (type == EquationType.None)
        {
            val = 0.0;
        }
        else if (type == EquationType.Linear)
        {
            val = Linear(t, b, c, d);
        }
        else if (type == EquationType.QuadEaseOut)
        {
            val = QuadEaseOut(t, b, c, d);
        }
        else if (type == EquationType.QuadEaseIn)
        {
            val = QuadEaseIn(t, b, c, d);
        }
        else if (type == EquationType.QuadEaseInOut)
        {
            val = QuadEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.QuadEaseOutIn)
        {
            val = QuadEaseOutIn(t, b, c, d);
        }
        else if (type == EquationType.ExpoEaseOut)
        {
            val = ExpoEaseOut(t, b, c, d);
        }
        else if (type == EquationType.ExpoEaseIn)
        {
            val = ExpoEaseIn(t, b, c, d);
        }
        else if (type == EquationType.ExpoEaseInOut)
        {
            val = ExpoEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.ExpoEaseOutIn)
        {
            val = ExpoEaseOutIn(t, b, c, d);
        }
        else if (type == EquationType.CubicEaseOut)
        {
            val = CubicEaseOut(t, b, c, d);
        }
        else if (type == EquationType.CubicEaseIn)
        {
            val = CubicEaseIn(t, b, c, d);
        }
        else if (type == EquationType.CubicEaseInOut)
        {
            val = CubicEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.CubicEaseOutIn)
        {
            val = CubicEaseOutIn(t, b, c, d);
        }
        else if (type == EquationType.QuartEaseOut)
        {
            val = QuartEaseOut(t, b, c, d);
        }
        else if (type == EquationType.QuartEaseInOut)
        {
            val = QuartEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.QuartEaseIn)
        {
            val = QuartEaseIn(t, b, c, d);
        }
        else if (type == EquationType.QuartEaseOutIn)
        {
            val = QuartEaseOutIn(t, b, c, d);
        }
        else if (type == EquationType.QuintEaseOut)
        {
            val = QuintEaseOut(t, b, c, d);
        }
        else if (type == EquationType.QuintEaseIn)
        {
            val = QuintEaseIn(t, b, c, d);
        }
        else if (type == EquationType.QuintEaseInOut)
        {
            val = QuintEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.QuintEaseOutIn)
        {
            val = QuintEaseOutIn(t, b, c, d);
        }
        else if (type == EquationType.CircEaseOut)
        {
            val = CircEaseOut(t, b, c, d);
        }
        else if (type == EquationType.CircEaseIn)
        {
            val = CircEaseIn(t, b, c, d);
        }
        else if (type == EquationType.CircEaseInOut)
        {
            val = CircEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.CircEaseOutIn)
        {
            val = CircEaseOutIn(t, b, c, d);
        }
        else if (type == EquationType.SineEaseOut)
        {
            val = SineEaseOut(t, b, c, d);
        }
        else if (type == EquationType.SineEaseIn)
        {
            val = SineEaseIn(t, b, c, d);
        }
        else if (type == EquationType.SineEaseInOut)
        {
            val = SineEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.SineEaseOutIn)
        {
            val = SineEaseOutIn(t, b, c, d);
        }
        else if (type == EquationType.ElasticEaseOut)
        {
            val = ElasticEaseOut(t, b, c, d);
        }
        else if (type == EquationType.ElasticEaseIn)
        {
            val = ElasticEaseIn(t, b, c, d);
        }
        else if (type == EquationType.ElasticEaseInOut)
        {
            val = ElasticEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.ElasticEaseOutIn)
        {
            val = ElasticEaseOutIn(t, b, c, d);
        }
        else if (type == EquationType.BounceEaseOut)
        {
            val = BounceEaseOut(t, b, c, d);
        }
        else if (type == EquationType.BounceEaseIn)
        {
            val = BounceEaseIn(t, b, c, d);
        }
        else if (type == EquationType.BounceEaseInOut)
        {
            val = BounceEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.BounceEaseOutIn)
        {
            val = BounceEaseOutIn(t, b, c, d);
        }


        else if (type == EquationType.BackEaseOut)
        {
            val = BackEaseOut(t, b, c, d);
        }
        else if (type == EquationType.BackEaseIn)
        {
            val = BackEaseIn(t, b, c, d);
        }
        else if (type == EquationType.BackEaseInOut)
        {
            val = BackEaseInOut(t, b, c, d);
        }
        else if (type == EquationType.BackEaseOutIn)
        {
            val = BackEaseOutIn(t, b, c, d);
        }

        return(val);
    }
Пример #29
0
 public object[] GetPositiveTestValues(EquationType equationType)
 {
     return(GetSelectedItems().Select(item => item.OriginalItem).ToArray());
 }
Пример #30
0
 public Equation(EquationType type, string name, System.Func <float, Vector3> func)
 {
     this.type = type;
     this.name = name;
     this.func = func;
 }
Пример #31
0
        private void get4Units(ref int first, ref int second, ref int third,
                               ref EquationMethod method1, ref EquationMethod method2,
                               EquationType type)
        {
            int carryCount = 0;

            while (true)
            {
                method1    = getRandomMethod();
                method2    = getRandomMethod();
                carryCount = 0;
                switch (mRandom.Next(0, 3))
                {
                case 0:
                    first  = get2DigitsNum();
                    second = get1DigitNum();
                    third  = get1DigitNum();
                    break;

                case 1:
                    first  = get1DigitNum();
                    second = get2DigitsNum();
                    third  = get1DigitNum();
                    break;

                case 2:
                    first  = get1DigitNum();
                    second = get1DigitNum();
                    third  = get2DigitsNum();
                    break;
                }

                if (ifCarry(first, second, method1) == EquationType.Carry)
                {
                    carryCount++;
                }

                int firstAndSecond = doCalc(first, second, method1);

                if (ifCarry(firstAndSecond, third, method2) == EquationType.Carry)
                {
                    carryCount++;
                }

                if (type == EquationType.Carry && doCalc(firstAndSecond, third, method2) >= 0)
                {
                    if (carryCount == 1)
                    {
                        break;
                    }
                }

                if (type == EquationType.NonCarry && doCalc(firstAndSecond, third, method2) >= 0)
                {
                    if (carryCount == 0)
                    {
                        break;
                    }
                }
            }
        }
Пример #32
0
 /// <summary>
 /// Sets the tween type.
 /// </summary>
 /// <param name="o">The o.</param>
 /// <param name="value">The value.</param>
 public static void SetType(DependencyObject o, EquationType value)
 {
     o.SetValue(TypeProperty, value);
 }
Пример #33
0
        public SimplexTuple BuildFromBasePlan(List<PlanStep> basePlan, List<Job> jobs, List<Resource> resources,
		                                      List<double[]> dependencyValues)
        {
            int tVarCounter = basePlan.Count;
            int xVarCounter = basePlan.Sum(step => step.ExecutingJobs.Count);
            //count final variable number
            int totalVariables = tVarCounter + xVarCounter;
            //count final inequality number (for each variable 1 non-negative condition and 2*intencity restrictions)
            //also adding 2 eq per each job -> total volumes for all stages should match initial total job volumes
            //also adding resource limitations per each stage
            int totalInequalities = totalVariables + 2*xVarCounter + resources.Count*basePlan.Count+2*jobs.Count;

            //initialize
            const ObjectiveFunctionType type = ObjectiveFunctionType.Min;
            var objFunctionCoeffs = new double[totalVariables];
            var eqTypes = new EquationType[totalInequalities];
            var eqCoeffs = new double[totalInequalities,totalVariables];
            var freeTerms = new double[totalInequalities];
            const double objFunctionFreeTerm = 0;
            //Fill help array
            var helpArrCnt = GenerateHelpDataArray(basePlan, xVarCounter);

            //Build objective function (to minimize total time -> coeffs for x's is zero) and non-negativity for t
            BuildNonNegativityInequalities(tVarCounter, xVarCounter, objFunctionCoeffs, eqCoeffs, eqTypes, freeTerms);

            int ineqCounter = totalVariables, xVarCnt1 = tVarCounter, xVarCnt2 = tVarCounter;
            for (int stepNumber = 0; stepNumber < basePlan.Count; stepNumber++)
            {
                //Create ineq for intensity part
                foreach (var executingJob in basePlan[stepNumber].ExecutingJobs)
                {
                    //Add inequalities for intencity limitations
                    //get min intensity for this job
                    eqCoeffs[ineqCounter, stepNumber] = executingJob.JobReference.MinimumIntensity;
                    eqCoeffs[ineqCounter, xVarCnt1] = -1;
                    eqTypes[ineqCounter] = EquationType.LessOrEqual;
                    freeTerms[ineqCounter++] = 0;

                    //get max intensity for this job
                    eqCoeffs[ineqCounter, stepNumber] = -1*executingJob.JobReference.MaximumIntensity;
                    eqCoeffs[ineqCounter, xVarCnt1++] = 1;
                    eqTypes[ineqCounter] = EquationType.LessOrEqual;
                    freeTerms[ineqCounter++] = 0;
                }

                //Add inequalities for resource limitations
                var xVarCnt3 = xVarCnt2;
                foreach (var resource in resources)
                {
                    eqCoeffs[ineqCounter, stepNumber] = -1*resource.Value;
                    foreach (var runningJob in basePlan[stepNumber].ExecutingJobs)
                    {
                        eqCoeffs[ineqCounter, xVarCnt2++] = dependencyValues[runningJob.JobReference.Number - 1][resource.Number - 1];
                    }
                    eqTypes[ineqCounter] = EquationType.LessOrEqual;
                    freeTerms[ineqCounter++] = 0;
                    xVarCnt2 = xVarCnt3;
                }
                xVarCnt2 += basePlan[stepNumber].ExecutingJobs.Count;
            }

            //Add inequalities for total work volumes (should remain disregarding work steps)
            foreach (var job in jobs)
            {
                var indexList = new List<int>();
                for (int x = 0; x < helpArrCnt.Length; x++)
                {
                    if (helpArrCnt[x] == job.Number) indexList.Add(x);
                }

                foreach (var i in indexList)
                {
                    eqCoeffs[ineqCounter, tVarCounter + i] = 1;
                }

                eqTypes[ineqCounter] = EquationType.LessOrEqual;
                freeTerms[ineqCounter++] = job.FullWorkVolume;

                foreach (var i in indexList)
                {
                    eqCoeffs[ineqCounter, tVarCounter + i] = -1;
                }

                eqTypes[ineqCounter] = EquationType.LessOrEqual;
                freeTerms[ineqCounter++] = -job.FullWorkVolume;
            }

            return new SimplexTuple(type, eqCoeffs, eqTypes.ToList(), freeTerms, objFunctionCoeffs, objFunctionFreeTerm);
        }
Пример #34
0
 public SolutionFinder(Dictionary <char, dynamic> inputs, dynamic output, dynamic acceptableCost, dynamic mutationRate, int populationSize, EquationType type, dynamic maxValue, dynamic minValue, EF_Equation seed)
 {
     fillOut(inputs, output, acceptableCost, mutationRate, populationSize, type, maxValue, minValue);
     this.seed = seed;
     initializePopulationWithSeed(this.seed);
 }
    /// <summary>
    /// Generic Easing equation function
    /// </summary>
    /// <param name="age">Current time in seconds.</param>
    /// <param name="valueStart">Starting value.</param>
    /// <param name="valueEnd">Final value.</param>
    /// <param name="maxTime">Duration of animation.</param>
    /// <returns>The correct value.</returns>
    public static float GetValue(EquationType type, double age, double valueStart, double valueEnd, double maxTime)
    {
        double val     = 0.0;
        bool   reverse = valueEnd < valueStart;

        // Swap start and end value if reversed
        if (reverse)
        {
            double tmp = valueStart;
            valueStart = valueEnd;
            valueEnd   = tmp;
        }

        // penner equations work with start and offset instead of start and end, so subtract (and add again later)
        valueEnd -= valueStart;

        if (type == EquationType.None)
        {
            val = 0.0;
        }
        else if (type == EquationType.Linear)
        {
            val = Linear(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuadEaseOut)
        {
            val = QuadEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuadEaseIn)
        {
            val = QuadEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuadEaseInOut)
        {
            val = QuadEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuadEaseOutIn)
        {
            val = QuadEaseOutIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.ExpoEaseOut)
        {
            val = ExpoEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.ExpoEaseIn)
        {
            val = ExpoEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.ExpoEaseInOut)
        {
            val = ExpoEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.ExpoEaseOutIn)
        {
            val = ExpoEaseOutIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.CubicEaseOut)
        {
            val = CubicEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.CubicEaseIn)
        {
            val = CubicEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.CubicEaseInOut)
        {
            val = CubicEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.CubicEaseOutIn)
        {
            val = CubicEaseOutIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuartEaseOut)
        {
            val = QuartEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuartEaseInOut)
        {
            val = QuartEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuartEaseIn)
        {
            val = QuartEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuartEaseOutIn)
        {
            val = QuartEaseOutIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuintEaseOut)
        {
            val = QuintEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuintEaseIn)
        {
            val = QuintEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuintEaseInOut)
        {
            val = QuintEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.QuintEaseOutIn)
        {
            val = QuintEaseOutIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.CircEaseOut)
        {
            val = CircEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.CircEaseIn)
        {
            val = CircEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.CircEaseInOut)
        {
            val = CircEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.CircEaseOutIn)
        {
            val = CircEaseOutIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.SineEaseOut)
        {
            val = SineEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.SineEaseIn)
        {
            val = SineEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.SineEaseInOut)
        {
            val = SineEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.SineEaseOutIn)
        {
            val = SineEaseOutIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.ElasticEaseOut)
        {
            val = ElasticEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.ElasticEaseIn)
        {
            val = ElasticEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.ElasticEaseInOut)
        {
            val = ElasticEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.ElasticEaseOutIn)
        {
            val = ElasticEaseOutIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.BounceEaseOut)
        {
            val = BounceEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.BounceEaseIn)
        {
            val = BounceEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.BounceEaseInOut)
        {
            val = BounceEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.BounceEaseOutIn)
        {
            val = BounceEaseOutIn(age, valueStart, valueEnd, maxTime);
        }


        else if (type == EquationType.BackEaseOut)
        {
            val = BackEaseOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.BackEaseIn)
        {
            val = BackEaseIn(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.BackEaseInOut)
        {
            val = BackEaseInOut(age, valueStart, valueEnd, maxTime);
        }
        else if (type == EquationType.BackEaseOutIn)
        {
            val = BackEaseOutIn(age, valueStart, valueEnd, maxTime);
        }

        // penner equations work with start and offset instead of start and end, so add (to compensate for eariler subtraction)
        valueEnd += valueStart;

        if (reverse)
        {
            // fix result for reversed tween
            val = valueStart - val + valueEnd;
        }
        return((float)val);
    }
Пример #36
0
 /// <summary>
 /// Deserialization constructor
 /// </summary>
 /// <param name="info">serialization info</param>
 /// <param name="context">stream context</param>
 public ValueCondition(SerializationInfo info, StreamingContext context)
 {
     _leftValue    = (IValue)info.GetValue("Left", typeof(IValue));
     _rightValue   = (IValue)info.GetValue("Right", typeof(IValue));
     _equationtype = (EquationType)info.GetValue("Equation", typeof(EquationType));
 }
Пример #37
0
 // For backward compatibility
 public static Storyboard CreateAnim(DependencyObject target, PropertyPath property, EquationType type, double to, TimeSpan duration)
 {
     return CreateAnim(target, type, duration, property, 0, to);
 }
Пример #38
0
        private void button26Plus_Click(object sender, EventArgs e)
        {
            firstNumberForEquation = TextboxToNumber(textBox1, Signed);
            switch ((sender as Button).Text)
            {
                case "+":
                    equationType = EquationType.Add;
                    break;
                case "-":
                    equationType = EquationType.Substract;
                    break;
                case "*":
                    equationType = EquationType.Multiply;
                    break;
                case "/":
                    equationType = EquationType.Divide;
                    break;
                case "x^y":
                    equationType = EquationType.Power;
                    break;
                default:
                    MessageBox.Show("Wrong function call", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
            }

            isNextButtonErasingTextbox = true;
        }
Пример #39
0
        internal void BuildNonNegativityInequalities(int tVarCounter, int xVarCounter, double[] objFunctionCoeffs,
		                                             double[,] eqCoeffs, EquationType[] eqTypes, double[] freeTerms)
        {
            for (int tnum = 0; tnum < tVarCounter; tnum++)
            {
                //Put non-negative coeffs to objective function
                objFunctionCoeffs[tnum] = 1;
                //Build eqCoeff matrix (A)
                //Add non-negativity to delta t
                eqCoeffs[tnum, tnum] = -1;
                eqTypes[tnum] = EquationType.LessOrEqual;
                freeTerms[tnum] = 0;
            }
            //non-negativity for x
            for (int xnum = 0; xnum < xVarCounter; xnum++)
            {
                eqCoeffs[tVarCounter + xnum, tVarCounter + xnum] = -1;
                eqTypes[tVarCounter + xnum] = EquationType.LessOrEqual;
                freeTerms[tVarCounter + xnum] = 0;
            }
        }