public IS2 Calculate( IS2ParameterElementFactory S2ParameterElementFactory, IS2Factory S2Factory, Id1 d1, Id2 d2, Ir r, It t, Ird1d2 rd1d2, IW W, Ix x, IΔ Δ) { return(S2Factory.Create( rd1d2.Value .Where(i => i.d1IndexElement.Value.Value.Value != i.d2IndexElement.Value.Value.Value) // rd1d2t1 .SelectMany(b => t.GetNthElementsAt( b.d1IndexElement.Value.Value.Value, t.GetT() - W.Value.Value.Value + b.d1IndexElement.Value.Value.Value, W.Value.Value.Value), (a, b) => Tuple.Create(a.rIndexElement, a.d1IndexElement, a.d2IndexElement, b)) // rd1d2t1t2 .SelectMany(b => t.GetNthElementsAt( b.Item3.Value.Value.Value, t.GetT() - W.Value.Value.Value + b.Item3.Value.Value.Value, W.Value.Value.Value), (a, b) => Tuple.Create(a.Item1, a.Item2, a.Item3, a.Item4, b)) .Select( i => Tuple.Create( i.Item1, i.Item2, i.Item3, i.Item4, i.Item5, // x(j, r, t) x.Value .Where(j => j.Value.Value.Value) .Select(j => Tuple.Create( Δ.GetSurgicalSpecialtyOfSurgeon(j.sIndexElement), j.rIndexElement, j.tIndexElement)) .Where(j => j.Item2 == i.Item1) .Select(j => j.Item1) .Distinct() .Count())) .Where(i => i.Item6 == 1) .Select(i => S2ParameterElementFactory .Create( i.Item1, i.Item2, i.Item3)) .ToImmutableList())); }
public IExpectedValueΦResultElement Calculate( IExpectedValueΦResultElementFactory expectedValueΦResultElementFactory, IlIndexElement lIndexElement, IsIndexElement sIndexElement, IΛIndexElement ΛIndexElement, Il l, It t, IL L, Ip p, Iμ μ) { int Ls = L.GetElementAtAsint( sIndexElement); int τLowerBound = 0; int τUpperBound = (int)Math.Floor( (decimal) (Ls - lIndexElement.Value.Value.Value) / t.GetT()); decimal sum = 0; for (int τ = τLowerBound; τ <= τUpperBound; τ = τ + 1) { int lPrimeLowerBound = lIndexElement.Value.Value.Value + τ * t.GetT() + 1; int lPrimeUpperBound = Ls; for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeUpperBound; lPrime = lPrime + 1) { sum += p.GetElementAtAsdecimal( sIndexElement, l.GetElementAt( lPrime), ΛIndexElement); } } return(expectedValueΦResultElementFactory.Create( sIndexElement, lIndexElement, ΛIndexElement, μ.GetElementAtAsdecimal( sIndexElement, ΛIndexElement) * sum)); }
public IVarianceIResultElement Calculate( IVarianceIResultElementFactory varianceIResultElementFactory, ItIndexElement tIndexElement, IΛIndexElement ΛIndexElement, Il l, It t, Ist st, IVarianceΦ varianceΦ, Iz z) { return(varianceIResultElementFactory.Create( tIndexElement, ΛIndexElement, st.Value .Select(w => varianceΦ.GetElementAtAsdecimal( w.sIndexElement, l.GetElementAt( tIndexElement.Key - w.tIndexElement.Key + (int)Math.Floor( (decimal)w.tIndexElement.Key / (tIndexElement.Key + 1)) * t.GetT()), ΛIndexElement) * z.GetElementAtAsint( w.sIndexElement, w.tIndexElement)) .Sum())); }
public Iδ4 Calculate( Iδ4ParameterElementFactory δ4ParameterElementFactory, Iδ4Factory δ4Factory, Iδ4ParameterElementCalculation δ4ParameterElementCalculation, Isrd srd, It t, IW W, Iδ3 δ3, Iγ γ) { return(δ4Factory.Create( srd.Value .SelectMany(b => t.GetNthElementsAt( b.dIndexElement.Value.Value.Value, t.GetT() - W.Value.Value.Value + b.dIndexElement.Value.Value.Value, W.Value.Value.Value), (a, b) => Tuple.Create(a.sIndexElement, a.rIndexElement, a.dIndexElement, b)) .Select(x => δ4ParameterElementCalculation.Calculate( δ4ParameterElementFactory, x.Item3, x.Item2, x.Item1, x.Item4, t, W, γ, δ3)) .ToImmutableList())); }
public Constraints6ConstraintElement( ItIndexElement tIndexElement, IΛIndexElement ΛIndexElement, Il l, It t, Ist st, IΦHat ΦVHat, IIHat IHat, Iz z) { Expression LHS = IHat.Value[tIndexElement, ΛIndexElement]; Expression RHS = Expression.Sum( st.Value .Select( y => (double)ΦVHat.GetElementAtAsdecimal( y.sIndexElement, l.GetElementAt( tIndexElement.Key - y.tIndexElement.Key + (int)Math.Floor( (decimal)(y.tIndexElement.Key) / (tIndexElement.Key + 1)) * t.GetT()), ΛIndexElement) * z.Value[y.sIndexElement, y.tIndexElement])); this.Value = LHS == RHS; }
public Iδ3ParameterElement Calculate( Iδ3ParameterElementFactory δ3ParameterElementFactory, IdIndexElement dIndexElement, IrIndexElement rIndexElement, IsIndexElement sIndexElement, It t, IW W, Iβ β, Iγ γ) { int value = 0; int γSum = t.GetNthElementsAt( dIndexElement.Value.Value.Value, t.GetT() - W.Value.Value.Value + dIndexElement.Value.Value.Value, W.Value.Value.Value) .Select( y => γ.GetElementAtAsint( rIndexElement, y)) .Sum(); int βAsint = β.GetElementAtAsint( sIndexElement, rIndexElement, dIndexElement); if (βAsint > 0) { // Case (i) if ((γSum % βAsint) == 0) { value = γSum / βAsint; } else if ((γSum % βAsint) != 0) { // Case (ii) if (βAsint < (γSum / 2)) { value = (int)Math.Floor( (decimal)(γSum / βAsint)); } // Case (iii) else if ((βAsint > (γSum / 2)) && (βAsint < γSum)) { value = (int)Math.Floor( (decimal)(γSum / (γSum - βAsint))); } } } return(δ3ParameterElementFactory.Create( sIndexElement, rIndexElement, dIndexElement, value)); }
public Constraints7ConstraintElement( IdIndexElement dIndexElement, IrIndexElement rIndexElement, IsIndexElement sIndexElement, It t, IW W, Ix x, Iβ β) { OPTANO.Modeling.Optimization.Expression LHS = OPTANO.Modeling.Optimization.Expression.Sum( t.GetNthElementsAt( dIndexElement.Value.Value.Value, t.GetT() - W.Value.Value.Value + dIndexElement.Value.Value.Value, W.Value.Value.Value) .Select( y => x.Value[sIndexElement, rIndexElement, y])); OPTANO.Modeling.Optimization.Expression RHS = β.Value[sIndexElement, rIndexElement, dIndexElement]; this.Value = LHS == RHS; }
public Constraints1ConstraintElement( IdIndexElement dIndexElement, IrIndexElement rIndexElement, IsIndexElement sIndexElement, It t, IW W, Iβ β, Ix x) { Expression LHS = Expression.Sum( t.GetNthElementsAt( dIndexElement.Value.Value.Value, t.GetT() - W.Value.Value.Value + dIndexElement.Value.Value.Value, W.Value.Value.Value) .Select( y => x.Value[sIndexElement, rIndexElement, y])); int RHS = β.GetElementAtAsint( sIndexElement, rIndexElement, dIndexElement); this.Value = LHS == RHS; }
public IVarianceΦResultElement Calculate( IVarianceΦResultElementFactory varianceΦResultElementFactory, IlIndexElement lIndexElement, IsIndexElement sIndexElement, IΛIndexElement ΛIndexElement, Il l, It t, IL L, Ip p, Iμ μ, Iσ σ) { int Ls = L.GetElementAtAsint( sIndexElement); int τLowerBound = 0; int τUpperBound = (int)Math.Floor( (decimal) (Ls - lIndexElement.Value.Value.Value) / t.GetT()); // Mean decimal meanSum = 0; for (int τ = τLowerBound; τ <= τUpperBound; τ = τ + 1) { int lPrimeLowerBound = lIndexElement.Value.Value.Value + τ * t.GetT() + 1; int lPrimeVarianceUpperBound = Math.Min( lIndexElement.Value.Value.Value + τ * t.GetT() + t.GetT(), Ls); int lPrimeCovarianceUpperBound = Math.Min( lIndexElement.Value.Value.Value + τ * t.GetT() + t.GetT(), Ls - 1); // Mean: Variance for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeVarianceUpperBound; lPrime = lPrime + 1) { meanSum += (τ + 1) * p.GetElementAtAsdecimal( sIndexElement, l.GetElementAt( lPrime), ΛIndexElement) * (1 - p.GetElementAtAsdecimal( sIndexElement, l.GetElementAt( lPrime), ΛIndexElement)); } // Mean: Covariance for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeCovarianceUpperBound; lPrime = lPrime + 1) { int lHatLowerBound = lPrime + 1; int lHatUpperBound = Ls; for (int lHat = lHatLowerBound; lHat <= lHatUpperBound; lHat = lHat + 1) { meanSum -= (τ + 1) * 2 * p.GetElementAtAsdecimal( sIndexElement, l.GetElementAt( lPrime), ΛIndexElement) * p.GetElementAtAsdecimal( sIndexElement, l.GetElementAt( lHat), ΛIndexElement); } } } // Variance decimal varianceSum = 0; for (int τ = τLowerBound; τ <= τUpperBound; τ = τ + 1) { int lPrimeLowerBound = lIndexElement.Value.Value.Value + τ * t.GetT() + 1; int lPrimeUpperBound = Ls; for (int lPrime = lPrimeLowerBound; lPrime <= lPrimeUpperBound; lPrime = lPrime + 1) { varianceSum += p.GetElementAtAsdecimal( sIndexElement, l.GetElementAt( lPrime), ΛIndexElement); } } return(varianceΦResultElementFactory.Create( sIndexElement, lIndexElement, ΛIndexElement, μ.GetElementAtAsdecimal( sIndexElement, ΛIndexElement) * meanSum + σ.GetElementAtAsdecimal( sIndexElement, ΛIndexElement) * σ.GetElementAtAsdecimal( sIndexElement, ΛIndexElement) * varianceSum * varianceSum)); }