public Constraints8ConstraintElement(
            Id2IndexElement d2IndexElement,
            IrIndexElement rIndexElement,
            IsIndexElement sIndexElement,
            ItIndexElement tIndexElement,
            Id1 d1,
            It t,
            Ix x,
            IxHat xHat,
            Iα α)
        {
            Expression LHS = xHat.Value[
                sIndexElement,
                rIndexElement,
                t.GetElementAt(
                    tIndexElement.Key + d2IndexElement.Value.Value.Value)];

            Expression RHS = Expression.Sum(
                d1.Value
                .Select(
                    y => x.GetElementAtAsint(
                        sIndexElement,
                        rIndexElement,
                        t.GetElementAt(
                            tIndexElement.Key + y.Value.Value.Value))
                    *
                    α.Value[rIndexElement, y, d2IndexElement]));

            this.Value = LHS == RHS;
        }
Example #2
0
        public Iδ4ParameterElement Calculate(
            Iδ4ParameterElementFactory δ4ParameterElementFactory,
            IdIndexElement dIndexElement,
            IrIndexElement rIndexElement,
            IsIndexElement sIndexElement,
            ItIndexElement tIndexElement,
            It t,
            IW W,
            Iγ γ,
            Iδ3 δ3)
        {
            Iδ4ParameterElement δ4ParameterElement = null;

            int γSum = 0;

            int δ3Asint = δ3.GetElementAtAsint(
                sIndexElement,
                rIndexElement,
                dIndexElement);

            if (δ3Asint == 0)
            {
                δ4ParameterElement = δ4ParameterElementFactory.Create(
                    sIndexElement,
                    rIndexElement,
                    dIndexElement,
                    tIndexElement,
                    1);
            }
            else
            {
                int δ4 = 1;

                do
                {
                    γSum = t.GetNthElementsAt(
                        dIndexElement.Value.Value.Value,
                        dIndexElement.Value.Value.Value + (δ4 - 1) * W.Value.Value.Value,
                        W.Value.Value.Value)
                           .Select(x => γ.GetElementAtAsint(
                                       rIndexElement,
                                       t.GetElementAt(x.Key)))
                           .Sum();

                    δ4 = δ4 + 1;
                } while (γSum < δ3Asint);

                if (γSum == δ3Asint)
                {
                    δ4ParameterElement = δ4ParameterElementFactory.Create(
                        sIndexElement,
                        rIndexElement,
                        dIndexElement,
                        tIndexElement,
                        δ4 - 1);     // Subtract 1 to account for last iteration of the do-while loop
                }
            }

            return(δ4ParameterElement);
        }