//780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780, 780 static void Main(string[] args) { CalculationData userinput = new UserInputReader().ReadUserInput(); if (userinput == null) { Console.WriteLine("Nem megfelelő beviteli adatok!"); Console.ReadKey(); return; } GoalSeek goalSeeker = new GoalSeek(userinput.ThmCalculation); GoalSeekResult seekResult = goalSeeker.SeekResult(userinput.IssueValue); Console.WriteLine(); Console.WriteLine("----------------"); if (seekResult.InputVariable.HasValue) { Console.Write("A számított THM: "); Console.WriteLine(Math.Round(seekResult.InputVariable.Value, 10).ToString("P8")); } else { Console.WriteLine("Nem sikerült kiszámolni!"); } Console.ReadKey(); }
/// <summary> /// /// </summary> /// <param name="ME_FOC_HOUR"></param> /// <param name="shopTestPowerToSfoc"></param> /// <param name="mcr"></param> /// <param name="LCV"></param> /// <param name="shopTestLCV"></param> /// <returns></returns> public double ConvertFocToPower(double ME_FOC_HOUR, SHIP_SHOPTEST_DATA shopTestPowerToSfoc, float mcr, double LCV = 9700, double shopTestLCV = 10200) // 연료사용량을 마력으로 환산 mass 연료사용량이 파라미터로 들어감. { if (ME_FOC_HOUR < 0) { return(-9999); } double SHAFT_POWER_FOC = 0; var focToPowerCalculation = new FocToPowerCalculation(shopTestPowerToSfoc.D, shopTestPowerToSfoc.C, shopTestPowerToSfoc.B, shopTestPowerToSfoc.A); var goalSeeker = new GoalSeek(focToPowerCalculation); var seekResult = goalSeeker.SeekResult((decimal)ME_FOC_HOUR); double d = shopTestPowerToSfoc.D; double c = shopTestPowerToSfoc.C; double b = shopTestPowerToSfoc.B; double a = shopTestPowerToSfoc.A; //for (int i = 0; i < mcr + 2000; i += 1000) //{ // var focIndex_i = (d * Math.Pow(i, 3) + c * Math.Pow(i, 2) + b * i + a) * i / 1000 * shopTestLCV / LCV; // if (focIndex_i > ME_FOC_HOUR) // { // for (int j = i - 1000; j < i; j += 100) // { // var focIndex_j = (d * Math.Pow(j, 3) + c * Math.Pow(j, 2) + b * j + a) * j / 1000 * shopTestLCV / LCV; // if (focIndex_j > ME_FOC_HOUR) // { // for (int k = j - 100; k < j; k++) // { // var focIndex_k = (d * Math.Pow(k, 3) + c * Math.Pow(k, 2) + b * k + a) * k / 1000 * shopTestLCV / LCV; // if (focIndex_k > ME_FOC_HOUR) // { // SHAFT_POWER_FOC = k; // return SHAFT_POWER_FOC; // } // } // } // } // } //} if (double.IsNaN(SHAFT_POWER_FOC) || SHAFT_POWER_FOC > mcr * 1.2 || SHAFT_POWER_FOC < 0) { return(-9999); } SHAFT_POWER_FOC = Math.Round(SHAFT_POWER_FOC, 2); return(SHAFT_POWER_FOC); }
public void TestGoalSeek([Values(1700, 1400, 1300)] decimal target) { // Given var tree = GetTree(); var goalSeek = new GoalSeek <GoalSeekContext>(() => new GoalSeekContext(0, target), tree, ModifyContext, GetTarget, GetStartValue); // When var result = goalSeek.GetGoalSeekValue(target); var executionTine = goalSeek.GetExecutionTine(); var iterations = goalSeek.GetIterations(); // Then var context = new GoalSeekContext(result, target); tree.Run(context); Assert.IsNotNull(context); var grossUp = (long)(context.TargetDecimal - context.Tax + context.DecimalToManipulate); Assert.AreEqual(target, grossUp); Assert.IsNotNull(iterations); Assert.IsNotNull(executionTine); }