"""
Created by: Madeleine Graham Macy
Date Modified: 8/5/2024

Contains class Engine
and class Engines
"""

from __future__ import division
import jmp_score as jmp
from math import *
import numpy as np
import random
from constants import *
import matplotlib.pyplot as plt


class Engine(object):
    """
    Is an Engine with a serial number and info about
    how many cycles remain on its LLPs as well as its EGTM.

    degrade_nn()
    Degrades the engine according to neural net information and aircraft
    location.
    Decreases cycles remaining for all LLPs (life-limited parts) by one.
    Increases the cycles since maintenance by one.

    degrade_phys()
    Degrades the engine according to a physical model (TBD)
    (!!!Does not exist yet!!!)

    Note: "CR" refers to "cycles remaining."
    """
    esn: str
    fan_CR: int
    core_CR: int
    lpt_CR: int
    cycles_since_maint: int
    EGTM_degC: float

    def __init__(self,
                 esn: str,
                 fan_CR: int,
                 core_CR: int,
                 lpt_CR: int,
                 cycles_since_maint: int,
                 EGTM_degC: float = 100):
        self.esn = esn
        self.fan_CR = fan_CR
        self.core_CR = core_CR
        self.lpt_CR = lpt_CR
        self.cycles_since_maint = cycles_since_maint
        self.EGTM_degC = EGTM_degC
        return

    def degrade_nn(self,
                   OAT_degC: float,
                   alt_ft: int,
                   runway_length_ft: int,
                   TOGW_lbs: int):

        cycles_since_maint = self.cycles_since_maint

        # REFERENCE
        H2_1 = tanh((174.164821787562 +
                     0.0150183700071807 *
                     OAT_degC +
                     0.000947143072086257 *
                     alt_ft +
                    0.0000423079257930463 *
                    TOGW_lbs +
                    -0.0151675872844966 *
                    runway_length_ft))

        H2_2 = tanh((1.01830492829757 +
                     0.0567232483844859 *
                     OAT_degC +
                     0.0000704466763794585 *
                     alt_ft + -
                    0.0000145053103233196 *
                    TOGW_lbs +
                    0.0000543367777941306 *
                    runway_length_ft))

        H2_3 = tanh((-2.27644562276078 +
                     0.015488175687018 *
                     OAT_degC +
                     0.0000778760831673512 *
                     alt_ft +
                    0.0000127003730027054 *
                    TOGW_lbs +
                    -0.0000069454345893263 *
                    runway_length_ft))

        H2_4 = tanh((47.0970249032349 +
                     0.0101091512130753 *
                     OAT_degC +
                     -0.000105290133280793 *
                     alt_ft +
                    0.0000143042262120981 *
                    TOGW_lbs +
                    -0.00409831577932796 *
                    runway_length_ft))

        H2_5 = 8.3275695007449 + \
            0.0286374794089978 * \
            OAT_degC + \
            0.000337088679082665 * \
            alt_ft + \
            0.0000073704792191387 * \
            TOGW_lbs + \
            -0.000971764515303416 * \
            runway_length_ft

        H2_6 = -11.8743758677331 +\
            0.0668068785427457 * \
            OAT_degC + \
            -0.00214856381165951 *\
            alt_ft + \
            0.0000189924865427877 * \
            TOGW_lbs +\
            0.000647997130014476 * \
            runway_length_ft

        H2_7 = -13.3795468783909 + \
            -0.00320566567716204 * \
            OAT_degC + \
            0.00179796955519473 *\
            alt_ft + \
            -0.0000246842497082961 * \
            TOGW_lbs + \
            0.0014433942820324 * \
            runway_length_ft

        H2_8 = -14.4774368396608 + \
            -0.0130214921834953 * \
            OAT_degC +\
            0.00330719487176896 * \
            alt_ft + - \
            0.0000012455519206328 * \
            TOGW_lbs + \
            0.00103585278621634 * \
            runway_length_ft

        H2_9 = jmp.exp(-((0.5 * jmp.pow((-4.88965465182652 +
                                         -0.0100065633335312 *
                                         OAT_degC +
                                         -0.000344349102456848 *
                                         alt_ft +
                                         0.0000047132830316258 *
                                         TOGW_lbs +
                                         0.000311174080599601 *
                                         runway_length_ft), 2))))

        H2_10 = jmp.exp(-((0.5 * jmp.pow((-11.2353984266547 +
                                          -0.0108351413636036 *
                                          OAT_degC +
                                          0.00110051814611241 *
                                          alt_ft +
                                          0.0000116558312962193 *
                                          TOGW_lbs +
                                          0.000965199915233237 *
                                          runway_length_ft), 2))))

        H2_11 = jmp.exp(-((0.5 * jmp.pow((40.5639191994154 +
                                          -0.00254452388757888 *
                                          OAT_degC +
                                          0.000229009546327252 *
                                          alt_ft +
                                          0.0000020639921729637 *
                                          TOGW_lbs +
                                          -0.00335664143024474 *
                                          runway_length_ft), 2))))

        H2_12 = jmp.exp(-((0.5 * jmp.pow((20.9985136934855 +
                                          -0.00559593937827498 *
                                          OAT_degC +
                                          -0.000425922153324789 *
                                          alt_ft +
                                          0.0000073481470450792 *
                                          TOGW_lbs +
                                          -0.00176787362649127 *
                                          runway_length_ft), 2))))

        H1_1 = tanh((0.851128637533044 +
                     -0.108299563589652 *
                     H2_1 +
                     1.64245520465694 *
                     H2_10 +
                     -0.284715902246175 *
                     H2_11 +
                     0.734356438045888 *
                     H2_12 +
                     0.306111381015951 *
                     H2_2 +
                     1.15235361931861 *
                     H2_3 +
                     0.325969194788733 *
                     H2_4 +
                     0.743184388679846 *
                     H2_5 +
                     -0.343302736090084 *
                     H2_6 +
                     1.76092072305976 *
                     H2_7 +
                     -1.20175686725659 *
                     H2_8 +
                     -1.78409325192986 *
                     H2_9))

        H1_2 = tanh((-0.0791822040188334 +
                     1.66421641209447 *
                     H2_1 +
                     8.9522319219804 *
                     H2_10 +
                     0.917476567984544 *
                     H2_11 +
                     -1.3154819485005 *
                     H2_12 +
                     0.771922544802388 *
                     H2_2 +
                     -0.0999427956362843 *
                     H2_3 +
                     -1.83700781947894 *
                     H2_4 +
                     -2.53089496277077 *
                     H2_5 +
                     0.560595163435119 *
                     H2_6 +
                     0.158792529267962 *
                     H2_7 +
                     1.21509148589036 *
                     H2_8 +
                     1.47916709245556 *
                     H2_9))

        H1_3 = tanh((-0.0601579460387387 +
                     -0.0184264656999116 *
                     H2_1 +
                     -3.01925094011184 *
                     H2_10 +
                     9.33937382993851 *
                     H2_11 +
                     3.39361965099569 *
                     H2_12 +
                     0.614893830043801 *
                     H2_2 + 0.927511197922047 *
                     H2_3 +
                     -0.295192658403999 *
                     H2_4 +
                     1.44199061311736 *
                     H2_5 +
                     -0.492863078769391 *
                     H2_6 +
                     2.29588484420714 *
                     H2_7 +
                     2.57888435588379 *
                     H2_8 +
                     -1.2711708964783 *
                     H2_9))

        H1_4 = tanh((0.812578770259727 +
                     0.607350271462214 *
                     H2_1 +
                     -2.41846116770632 *
                     H2_10 +
                     0.37621463301884 *
                     H2_11 +
                     1.61883936835252 *
                     H2_12 +
                     0.0303136804626097 *
                     H2_2 +
                     0.116824919770507 *
                     H2_3 +
                     -0.267984762850041 *
                     H2_4 +
                     1.36990489589426 *
                     H2_5 +
                     1.31706787216699 *
                     H2_6 +
                     -0.198169109109344 *
                     H2_7 +
                     0.737072289966816 *
                     H2_8 +
                     0.995867279263292 *
                     H2_9))

        H1_5 = -0.856424210781424 + \
            -0.991920825452957 * \
            H2_1 + \
            2.01329600233579 *\
            H2_10 + \
            1.63490294066566 *\
            H2_11 + \
            -1.04804673924758 *\
            H2_12 + \
            -2.84364828019787 * \
            H2_2 + \
            -0.81994541263742 *\
            H2_3 +\
            -0.650698173902487 *\
            H2_4 +\
            -1.12519082987031 *\
            H2_5 +\
            0.841303164436202 * \
            H2_6 + \
            -1.54057917089817 *\
            H2_7 + 2.3540270374098 *\
            H2_8 + \
            1.16184356906571 *\
            H2_9

        H1_6 = 3.73153627321292 + \
            -0.733534743235999 * \
            H2_1 +\
            -0.842805608706391 * \
            H2_10 + \
            1.03439389195872 * \
            H2_11 +\
            -0.778218112305387 *\
            H2_12 +\
            0.851639458813897 *\
            H2_2 +\
            -3.82555326745561 * \
            H2_3 +\
            1.06750437669271 *\
            H2_4 +\
            0.0139769097808124 *\
            H2_5 +\
            0.226994289201912 * \
            H2_6 +\
            -1.96321417947815 * \
            H2_7 +\
            0.516495639704889 * \
            H2_8 +\
            -0.254450117592212 *\
            H2_9

        H1_7 = -4.42109924217421 +\
            0.353080098643115 * \
            H2_1 + \
            1.17773336734786 * \
            H2_10 +\
            -1.35065842566458 *\
            H2_11 + \
            0.610192195165197 * \
            H2_12 + \
            -2.06965889558599 * \
            H2_2 +\
            6.12296124080088 * \
            H2_3 +\
            0.109611786505414 * \
            H2_4 + \
            -0.024498521882812 * \
            H2_5 +\
            0.270452407977642 * \
            H2_6 +\
            -1.06604504722132 * \
            H2_7 +\
            -0.821097310899443 *\
            H2_8 + \
            0.886383372866355 *\
            H2_9

        H1_8 = 1.17549338131375 + \
            1.24076735925444 * \
            H2_1 + \
            -1.75426598084629 *\
            H2_10 + \
            -0.293506856274672 *\
            H2_11 +\
            -0.986270258038301 *\
            H2_12 +\
            0.898205500560073 * \
            H2_2 +\
            -5.24661188556761 * \
            H2_3 + \
            0.502446722785196 * \
            H2_4 + \
            0.314957671669226 *\
            H2_5 +\
            1.19308628004163 * \
            H2_6 +\
            -2.22767828866015 * \
            H2_7 +\
            -0.54225204104445 *\
            H2_8 +\
            -2.60806817035206 *\
            H2_9

        H1_9 = jmp.exp(-((0.5 * jmp.pow((1.72275141037306 +
                                         -3.20746624322573 *
                                         H2_1 +
                                         -0.277360153564307 *
                                         H2_10 +
                                         0.679583317787098 *
                                         H2_11 +
                                         1.60979892163742 *
                                         H2_12 +
                                         3.74852891723103 *
                                         H2_2 +
                                         0.363933115514676 *
                                         H2_3 +
                                         2.12717822593958 *
                                         H2_4 +
                                         3.3801271657094 *
                                         H2_5 +
                                         -1.81173472033208 *
                                         H2_6 +
                                         -1.99694118966928 *
                                         H2_7 +
                                         -0.300158534622706 *
                                         H2_8 +
                                         -2.41674956621846 *
                                         H2_9), 2))))

        H1_10 = jmp.exp(-((0.5 * jmp.pow((-1.49708115498306 +
                                          -4.37560146763932 *
                                          H2_1 +
                                          -0.493201043435781 *
                                          H2_10 +
                                          -1.056108417308 *
                                          H2_11 +
                                          -0.68734030056216 *
                                          H2_12 +
                                          -0.97870840617636 *
                                          H2_2 +
                                          1.89136422553161 *
                                          H2_3 +
                                          4.35324680005191 *
                                          H2_4 +
                                          1.07547051493475 *
                                          H2_5 +
                                          0.608689534896784 *
                                          H2_6 +
                                          -1.40201205133433 *
                                          H2_7 +
                                          1.42320599744481 *
                                          H2_8 +
                                          6.3469894710242 *
                                          H2_9), 2))))

        H1_11 = jmp.exp(-((0.5 * jmp.pow((-4.34544834927136 +
                                          -4.7489574464523 *
                                          H2_1 +
                                          2.90439968365315 *
                                          H2_10 +
                                          -8.75068759006729 *
                                          H2_11 +
                                          2.27051058068487 *
                                          H2_12 +
                                          -0.664457566353004 *
                                          H2_2 + -4.04341841042835 *
                                          H2_3 +
                                          5.4741452306019 *
                                          H2_4 +
                                          2.33993676738096 *
                                          H2_5 +
                                          0.91851220105594 *
                                          H2_6 +
                                          -0.113124431487999 *
                                          H2_7 +
                                          0.596527550498576 *
                                          H2_8 +
                                          10.2083896518651 *
                                          H2_9), 2))))

        H1_12 = jmp.exp(-((0.5 * jmp.pow((0.337250157024277 +
                                          -1.00994998041862 *
                                          H2_1 +
                                          -0.594879893668468 *
                                          H2_10 +
                                          -1.7995459093753 *
                                          H2_11 +
                                          7.56059754290742 *
                                          H2_12 +
                                          -2.92469500628587 *
                                          H2_2 +
                                          1.42640261880607 *
                                          H2_3 +
                                          0.97368626307282 *
                                          H2_4 +
                                          2.87223769375986 *
                                          H2_5 +
                                          1.69172646458289 *
                                          H2_6 +
                                          -1.08159633356989 *
                                          H2_7 +
                                          1.64358833475413 *
                                          H2_8 +
                                          -1.49711821410107 *
                                          H2_9), 2))))

        n1_derate = 2.90057364503678 + \
            8.7852876107355 * \
            H1_1 +\
            -4.82738060076072 *\
            H1_10 + \
            9.73091182780243 * \
            H1_11 + \
            -3.21670694310469 *\
            H1_12 +\
            3.17762957603113 *\
            H1_2 + \
            3.43543452703158 *\
            H1_3 + \
            -0.459843481931124 *\
            H1_4 + \
            2.14445982666793 * \
            H1_5 +\
            1.2008015789921 * \
            H1_6 +\
            -4.31131218126633 *\
            H1_7 + \
            3.21290983891735 * \
            H1_8 +\
            -1.10152213041725 *\
            H1_9

        ##########################################################################
        # n1_derate randomization occurs here
        ##########################################################################

        derate_randomization_percentage = 25

        if n1_derate < 0:
            n1_derate = 0.001
        rand_pred_n1_derate = \
            np.random.triangular((1-(derate_randomization_percentage/100))
                                 * n1_derate, n1_derate,
                                 (1+(derate_randomization_percentage/100))
                                 * n1_derate)
        if rand_pred_n1_derate < 0:
            rand_pred_n1_derate = 0

        H2_1_1 = tanh((3.87097653746827 +
                       0.0280342577983546 *
                       OAT_degC +
                       0.000175881737374565 *
                       alt_ft +
                       -0.0000861962108971477 *
                       cycles_since_maint + -
                      0.0000305811977653951 *
                      TOGW_lbs +
                      0.0222902613874303 *
                      rand_pred_n1_derate +
                      0.0000461489488491519 *
                      runway_length_ft))

        H2_2_1 = tanh((7.10475872544167 +
                       -0.0447981502559777 *
                       OAT_degC +
                       -0.000199935716336436 *
                       alt_ft +
                       0.0000560871368327859 *
                       cycles_since_maint +
                       -0.0000351222370513881 *
                       TOGW_lbs +
                       0.0304871706147175 *
                       rand_pred_n1_derate +
                       -0.0000865707582502279 *
                       runway_length_ft))

        H2_3_1 = tanh((-3.33831661308874 +
                       0.010335967114618 *
                       OAT_degC +
                       0.0000175622645677883 *
                       alt_ft +
                       0.000237985057885064 *
                       cycles_since_maint +
                      0.0000053011529064076 *
                      TOGW_lbs +
                      0.000478469101390496 *
                      rand_pred_n1_derate +
                       0.000070132429936017 *
                       runway_length_ft))

        H2_4_1 = tanh((-5.93831738257207 +
                       0.0207877910019095 *
                       OAT_degC +
                       -0.000456700056833265 *
                       alt_ft +
                       -0.0000366663914083389 *
                       cycles_since_maint +
                      0.0000375361351772083 *
                      TOGW_lbs +
                       0.00497686230083288 *
                       rand_pred_n1_derate +
                       -0.0000187078359901544 *
                       runway_length_ft))

        H2_5_1 = tanh((2.28493756784204 +
                       -0.00587972701260045 *
                       OAT_degC +
                       0.000275248564100462 *
                       alt_ft +
                       0.0000247368905100449 *
                       cycles_since_maint +
                      0.0000023051461060682 *
                      TOGW_lbs +
                      -0.0153888755455835 *
                      rand_pred_n1_derate +
                      -0.000219163065070404 *
                      runway_length_ft))

        H2_6_1 = tanh((-0.731679059093489 +
                       -0.0153613396763209 *
                       OAT_degC +
                       0.000181504159614983 *
                       alt_ft +
                       0.0000235692144037898 *
                      cycles_since_maint +
                       -0.0000035753846507255 *
                       TOGW_lbs +
                       -0.0134449946343108 *
                       rand_pred_n1_derate +
                       0.000146193874028894 *
                       runway_length_ft))

        H2_7_1 = -0.0472633573023041 +\
            0.00565013378430554 * \
            OAT_degC + \
            -0.0000659615373059723 * \
            alt_ft + \
            -0.000328148143898803 * \
            cycles_since_maint + \
            0.0000099863663363883 *\
            TOGW_lbs + \
            0.0411549546193622 * \
            rand_pred_n1_derate + \
            0.0000205126965097397 * \
            runway_length_ft

        H2_8_1 = 8.58226892177825 + \
            -0.0108305165886741 * \
            OAT_degC + \
            -0.000407712267435268 *\
            alt_ft + \
            -0.000185445188792875 * \
            cycles_since_maint +\
            -0.0000213893456149655 * \
            TOGW_lbs + - \
            0.124752349969719 * \
            rand_pred_n1_derate + - \
            0.000203100460179 *\
            runway_length_ft

        H2_9_1 = 9.55741589336583 + \
            0.0673297524163601 * \
            OAT_degC + \
            0.000211672418931647 *\
            alt_ft +\
            0.000105637869399919 *\
            cycles_since_maint + - \
            0.0000634683546750456 *\
            TOGW_lbs + \
            0.0531619272400084 * \
            rand_pred_n1_derate + \
            -0.00013519032178452 * \
            runway_length_ft

        H2_10_1 = -0.910547572058839 +\
            0.0366254278842287 *\
            OAT_degC +\
            -0.000592303863120266 *\
            alt_ft + \
            -0.000138219946239369 *\
            cycles_since_maint + \
            0.0000057359517910135 *\
            TOGW_lbs +\
            0.0893782768152271 * \
            rand_pred_n1_derate + \
            -0.0000204294617808335 * \
            runway_length_ft

        H2_11_1 = 5.24147077575014 + \
            -0.110789239250119 * \
            OAT_degC +\
            0.000259179541466903 * \
            alt_ft + \
            -0.000134701631048161 * \
            cycles_since_maint + - \
            0.0000274694918821557 *\
            TOGW_lbs +\
            -0.00508048668237046 * \
            rand_pred_n1_derate +\
            0.000213419201418101 * \
            runway_length_ft

        H2_12_1 = -4.0486908953105 +\
            0.0563845697483131 *\
            OAT_degC + \
            0.000297325799578212 * \
            alt_ft + \
            -0.00014975033074655 * \
            cycles_since_maint + \
            0.0000031173777717818 *\
            TOGW_lbs + \
            -0.0566787155295164 * \
            rand_pred_n1_derate +\
            0.000220187902493184 * \
            runway_length_ft

        H2_13_1 = jmp.exp(-((0.5 * jmp.pow((3.82120884055762 +
                                            0.00847921769155168 *
                                            OAT_degC +
                                            -0.00219634131465559 *
                                            alt_ft +
                                            0.0000244311022339467 *
                                            cycles_since_maint +
                                            -0.000033916886542443 *
                                            TOGW_lbs +
                                            -0.067746977691975 *
                                            rand_pred_n1_derate +
                                            0.000398908540548498 *
                                            runway_length_ft), 2))))

        H2_14_1 = jmp.exp(-((0.5 * jmp.pow((5.23767544398985 +
                                            -0.147249652015216 *
                                            OAT_degC +
                                            -0.000601013957625873 *
                                            alt_ft +
                                            -0.0000206437518170176 *
                          cycles_since_maint +
                          -0.0000007675658957586 *
                          TOGW_lbs +
                          0.00590183110004262 *
                          rand_pred_n1_derate +
                          -0.0000187023694796093 *
                          runway_length_ft), 2))))

        H2_15_1 = jmp.exp(-((0.5 * jmp.pow((-11.1318585041753 +
                                            0.0628072613943432 *
                                            OAT_degC +
                                            0.000956597140157948 *
                                            alt_ft +
                                            0.0000222719459914324 *
                          cycles_since_maint +
                          0.0000174323914740985 *
                          TOGW_lbs +
                          0.0299389177256089 *
                          rand_pred_n1_derate +
                          0.000537965804031497 *
                          runway_length_ft), 2))))

        H2_16_1 = jmp.exp(-((0.5 * jmp.pow((-6.91825234546525 +
                                            -0.0361563994113747 *
                                            OAT_degC +
                                            -0.00104655809809396 *
                                            alt_ft +
                                            0.0000190104957682618 *
                          cycles_since_maint +
                            -0.0000054530738765793 *
                            TOGW_lbs +
                            -0.0135813583173871 *
                            rand_pred_n1_derate +
                                            0.000783610065901488 *
                                            runway_length_ft), 2))))

        H2_17_1 = jmp.exp(-((0.5 * jmp.pow((14.2603240010516 +
                                            -0.0555802738702679 *
                                            OAT_degC +
                                            0.000007778345400371 *
                                            alt_ft +
                                            0.0000145377240709288 *
                          cycles_since_maint +
                          -0.0000222040188324996 *
                            TOGW_lbs +
                                            -0.0274067204953017 *
                                            rand_pred_n1_derate +
                                            -0.000779830243675701 *
                                            runway_length_ft), 2))))

        H2_18_1 = jmp.exp(-((0.5 * jmp.pow((10.697932643954 +
                                            -0.00107397586335005 *
                                            OAT_degC +
                                            -0.000416484670637215 *
                                            alt_ft +
                                            0.0000134616497221374 *
                          cycles_since_maint +
                          0.0000046850703516259 *
                          TOGW_lbs +
                            0.0012229135386195 *
                            rand_pred_n1_derate +
                                            -0.000817728008195142 *
                                            runway_length_ft), 2))))

        H1_1_1 = tanh((-0.210296995267164 +
                       -0.0123033325511553 *
                       H2_1_1 +
                       -0.141778432234927 *
                       H2_10_1 +
                       -0.246042738513232 *
                       H2_11_1 +
                       0.139172173023996 *
                       H2_12_1 +
                       -0.0896226050116433 *
                       H2_13_1 +
                       -0.0760125594569647 *
                       H2_14_1 +
                       -0.0522394460036675 *
                       H2_15_1 +
                       0.0852430014120027 *
                       H2_16_1 +
                      0.0999636313387697 *
                      H2_17_1 +
                      -0.0875980804881452 *
                      H2_18_1 +
                      -0.0135624094303232 *
                      H2_2_1 +
                      0.0735152495333425 *
                      H2_3_1 +
                      0.115772601933675 *
                      H2_4_1 +
                      -0.0151690131842787 *
                      H2_5_1 +
                      0.0460631059234146 *
                      H2_6_1 +
                       -0.32771123426826 *
                       H2_7_1 +
                       -0.218092489969137 *
                       H2_8_1 +
                       -0.0105437199878345 *
                       H2_9_1))

        H1_2_1 = tanh((-0.265412885693325 +
                       -0.272507465310425 *
                       H2_1_1 +
                       -0.425496778421572 *
                       H2_10_1 +
                       -0.17943686157575 *
                       H2_11_1 +
                       0.599118251729463 *
                       H2_12_1 +
                       -0.00604757782682541 *
                       H2_13_1 +
                       -0.244015601387935 *
                       H2_14_1 +
                       0.0302831800719717 *
                       H2_15_1 +
                       -0.143055267421263 *
                       H2_16_1 +
                       -0.0104202598976084 *
                      H2_17_1 +
                      -0.0116225258412074 *
                       H2_18_1 +
                       0.582377736544845 *
                       H2_2_1 +
                       0.0692682086234926 *
                       H2_3_1 +
                       -0.0481676552607904 *
                       H2_4_1 +
                       -0.00889231358432505 *
                       H2_5_1 +
                       -0.0779190862792592 *
                       H2_6_1 +
                       -0.269457598189418 *
                       H2_7_1 +
                       0.523027306304918 *
                       H2_8_1 +
                       -0.450897148683874 *
                       H2_9_1))

        H1_3_1 = tanh((-0.00892597302447907 +
                       0.0291651802406506 *
                       H2_1_1 +
                       -0.038492223529273 *
                       H2_10_1 +
                       -0.0578701801136508 *
                       H2_11_1 +
                       -0.0217779401441155 *
                       H2_12_1 +
                       0.00900968387665714 *
                       H2_13_1 +
                       0.00112996864687473 *
                       H2_14_1 +
                       0.0163723212350254 *
                       H2_15_1 +
                       -0.0195571820904453 *
                       H2_16_1 +
                       -0.0160883791090023 *
                       H2_17_1 +
                       -0.0749498868310159 *
                       H2_18_1 +
                       0.03721784503171 *
                       H2_2_1 +
                       -0.0114236973221422 *
                       H2_3_1 +
                       -0.0242837644544957 *
                       H2_4_1 +
                       -0.0167358273326369 *
                       H2_5_1 +
                       0.0586190222019272 *
                       H2_6_1 +
                       -0.0471690434896757 *
                       H2_7_1 +
                       0.022675660886015 *
                       H2_8_1 +
                       0.103820210374688 *
                       H2_9_1))

        H1_4_1 = tanh((-0.114580648641034 +
                       -0.13485185465782 *
                       H2_1_1 +
                       0.097126085074532 *
                       H2_10_1 +
                       -0.214446446111474 *
                       H2_11_1 +
                       0.301308515100926 *
                       H2_12_1 +
                       -0.202391429404533 *
                       H2_13_1 +
                       -0.187310329142744 *
                       H2_14_1 +
                       0.395201440898779 *
                       H2_15_1 +
                       -0.306718535423445 *
                       H2_16_1 +
                       0.0216530384813532 *
                      H2_17_1 +
                      -0.382272725062622 *
                      H2_18_1 +
                      0.0270788317289997 *
                      H2_2_1 +
                      0.125557894916021 *
                      H2_3_1 +
                      0.0711419767716952 *
                       H2_4_1 +
                       -0.0621634774390786 *
                       H2_5_1 +
                       -0.127262160418274 *
                       H2_6_1 +
                       -0.040792557182331 *
                       H2_7_1 +
                       0.170560241001599 *
                       H2_8_1 +
                       0.254782095461612 *
                       H2_9_1))

        H1_5_1 = tanh((0.149433533114903 + 0.115778829172969 * H2_1_1 + 0.163671992847323 * H2_10_1 + -0.219644140691348 * H2_11_1 + 0.0332127644529657 * H2_12_1 + -0.100795523421998 * H2_13_1 + 0.214190523659682 * H2_14_1 + 0.0397669601073783 * H2_15_1 + -0.255509267496964 * H2_16_1 + 0.208761337183765 *
                      H2_17_1 + -0.437047397299986 * H2_18_1 + -0.45893078378474 * H2_2_1 + -0.0877701028010017 * H2_3_1 + 0.126467785310149 * H2_4_1 + -0.0776693027490542 * H2_5_1 + 0.0146301169537294 * H2_6_1 + 0.0317991351164752 * H2_7_1 + -0.266822207527166 * H2_8_1 + 0.310435635225406 * H2_9_1))

        H1_6_1 = tanh((-0.218751551024691 + 0.12183670470532 * H2_1_1 + -0.0803305382466221 * H2_10_1 + 0.130899885879507 * H2_11_1 + 0.234507271774673 * H2_12_1 + 0.0567113576993689 * H2_13_1 + 0.214000593018519 * H2_14_1 + 0.0830379814401789 * H2_15_1 + 0.173046229296445 * H2_16_1 + 0.0243844329119177 *
                      H2_17_1 + -0.14193133902221 * H2_18_1 + 0.0251017699419994 * H2_2_1 + 0.0371862589314573 * H2_3_1 + -0.024209415982397 * H2_4_1 + 0.0886675438695691 * H2_5_1 + -0.23163077812873 * H2_6_1 + 0.0180384730498385 * H2_7_1 + 0.280279901571398 * H2_8_1 + -0.0042647952515823 * H2_9_1))

        H1_7_1 = 0.12873364417657 + 0.0178332958236709 * H2_1_1 + 0.0249007119752557 * H2_10_1 + 0.0881388099460336 * H2_11_1 + -0.00119089464514913 * H2_12_1 + -0.0204003839158811 * H2_13_1 + 0.16671928208204 * H2_14_1 + -0.0173364177308842 * H2_15_1 + 0.0599976908526082 * H2_16_1 + - \
            0.0621853186858469 * H2_17_1 + 0.106005903362234 * H2_18_1 + -0.0632720266100166 * H2_2_1 + 0.122185015657916 * H2_3_1 + -0.09897557491244 * H2_4_1 + \
            0.0923933026347277 * H2_5_1 + -0.119655047059482 * H2_6_1 + 0.155566539093973 * \
            H2_7_1 + 0.0660745816501603 * H2_8_1 + -0.0378780794039895 * H2_9_1

        H1_8_1 = -0.0995529429080711 + -0.0449106356441903 * H2_1_1 + -0.0754378974680888 * H2_10_1 + -0.1186034409318 * H2_11_1 + 0.00806415892706063 * H2_12_1 + 0.0236553417236706 * H2_13_1 + -0.121425272951451 * H2_14_1 + -0.0478862986325866 * H2_15_1 + -0.0289059395489169 * H2_16_1 + \
            0.11160762080487 * H2_17_1 + -0.101439752420755 * H2_18_1 + 0.0937881163546217 * H2_2_1 + -0.104201463746245 * H2_3_1 + 0.0981180359453212 * H2_4_1 + - \
            0.143029005984706 * H2_5_1 + 0.148627563025411 * H2_6_1 + -0.135062142192853 * \
            H2_7_1 + -0.0509707822727457 * H2_8_1 + 0.00350288306333693 * H2_9_1

        H1_9_1 = 0.105716329070239 + 0.0627183647836477 * H2_1_1 + 0.0986704700972174 * H2_10_1 + 0.171266387451178 * H2_11_1 + -0.0491891383771212 * H2_12_1 + -0.00607393991070239 * H2_13_1 + 0.158053920467364 * H2_14_1 + 0.036139020368306 * H2_15_1 + 0.0873843224949578 * H2_16_1 + - \
            0.0817975084800823 * H2_17_1 + 0.162245907369364 * H2_18_1 + -0.118393581555658 * H2_2_1 + 0.199806605600871 * H2_3_1 + -0.137531847059336 * H2_4_1 + \
            0.17234926247131 * H2_5_1 + -0.236222925263099 * H2_6_1 + 0.198089120004223 * \
            H2_7_1 + 0.013751320507291 * H2_8_1 + -0.0439275980729064 * H2_9_1

        H1_10_1 = -0.0291719618274003 + 0.0505868900383836 * H2_1_1 + -0.0122943150942606 * H2_10_1 + -0.0384556377188337 * H2_11_1 + 0.0385681195513219 * H2_12_1 + -0.0154976373794634 * H2_13_1 + -0.00271892444808734 * H2_14_1 + -0.084028155285514 * H2_15_1 + -0.0635706254505327 * H2_16_1 + \
            0.00523118697936274 * H2_17_1 + 0.0140489184542031 * H2_18_1 + 0.0241569653519576 * H2_2_1 + -0.0269264159097883 * H2_3_1 + 0.0157157675531292 * H2_4_1 + - \
            0.0313997051417545 * H2_5_1 + 0.078524821368663 * H2_6_1 + 0.0187261485600662 * \
            H2_7_1 + 0.000212396213270248 * H2_8_1 + 0.0377660151469594 * H2_9_1

        H1_11_1 = -0.0317639567721912 + -0.0142656431468822 * H2_1_1 + -0.0389308413179387 * H2_10_1 + -0.0432051091197373 * H2_11_1 + 0.0295124860043135 * H2_12_1 + -0.0103909383300708 * H2_13_1 + -0.047467599395529 * H2_14_1 + 0.0255522291304017 * H2_15_1 + -0.0332397739086697 * H2_16_1 + - \
            0.0173508878521065 * H2_17_1 + -0.014810677069511 * H2_18_1 + 0.0278784447424492 * H2_2_1 + 0.00227262433615975 * H2_3_1 + 0.0143367692107757 * H2_4_1 + - \
            0.0254981085216542 * H2_5_1 + 0.0165124523472519 * H2_6_1 + -0.0147556352970393 * \
            H2_7_1 + -0.00906933251470102 * H2_8_1 + 0.0290565542839573 * H2_9_1

        H1_12_1 = 0.41464971790619 + 0.0313862648283103 * H2_1_1 + 0.289872676257492 * H2_10_1 + 0.427715972627544 * H2_11_1 + -0.141241192773735 * H2_12_1 + -0.0868386870438648 * H2_13_1 + 0.550704041235776 * H2_14_1 + 0.0531015380112605 * H2_15_1 + 0.324093103068797 * H2_16_1 + -0.269301082362803 * \
            H2_17_1 + 0.457891295199264 * H2_18_1 + -0.356608303002405 * H2_2_1 + 0.546926083649717 * H2_3_1 + -0.462343983231286 * H2_4_1 + \
            0.486848515031015 * H2_5_1 + -0.618903360325783 * H2_6_1 + 0.639106703436068 * \
            H2_7_1 + 0.157578016334705 * H2_8_1 + -0.0489049543075454 * H2_9_1

        H1_13_1 = jmp.exp(-((0.5 * jmp.pow((-0.218413131825808 +
                                            0.171856247192221 *
                                            H2_1_1 +
                                            0.178800033903368 *
                                            H2_10_1 +
                                            -0.192873420992058 *
                                            H2_11_1 +
                                            -0.140774150369086 *
                                            H2_12_1 +
                                            -0.166897695791908 *
                                            H2_13_1 +
                                            -0.156797745057997 *
                                            H2_14_1 +
                                            -0.444661586947161 *
                                            H2_15_1 +
                                            0.0318313983815137 *
                                            H2_16_1 +
                          0.236515648258599 *
                          H2_17_1 +
                            -0.18391655410077 *
                                            H2_18_1 +
                                            0.251798343747853 *
                                            H2_2_1 +
                                            -0.0360771307199465 *
                                            H2_3_1 +
                                            0.881160743973207 *
                                            H2_4_1 +
                                            -0.0959063499428145 *
                                            H2_5_1 +
                                            0.39235970593123 *
                                            H2_6_1 +
                                            0.333990007368626 *
                                            H2_7_1 +
                                            -0.630245843923043 *
                                            H2_8_1 +
                                            0.44056820528002 *
                                            H2_9_1), 2))))

        H1_14_1 = jmp.exp(-((0.5 * jmp.pow((0.527718073781037 +
                                            -0.325280480813892 *
                                            H2_1_1 +
                                            -0.135366620676507 * H2_10_1 + 0.616188662345391 * H2_11_1 + 0.368897451163304 * H2_12_1 + 1.84695883585929 * H2_13_1 + -0.809708823149772 * H2_14_1 + 0.244391747918192 * H2_15_1 + -1.04152196398353 * H2_16_1 +
                          1.02700212733067 * H2_17_1 + 1.21857347643319 * H2_18_1 + -0.308937092555415 * H2_2_1 + 0.833514116414842 * H2_3_1 + 0.212400064289121 * H2_4_1 + -0.471994696348804 * H2_5_1 + 0.0559786058423269 * H2_6_1 + 0.00935288505367367 * H2_7_1 + 0.102399271366053 * H2_8_1 + 0.317625959666211 * H2_9_1), 2))))

        H1_15_1 = jmp.exp(-((0.5 * jmp.pow((0.113639502637371 + -0.0407619390815003 * H2_1_1 + 0.782872910745383 * H2_10_1 + -0.00122573764205695 * H2_11_1 + -0.0199906115512351 * H2_12_1 + 0.43867597430897 * H2_13_1 + 0.70016104450024 * H2_14_1 + 0.187889291581387 * H2_15_1 + 0.638612063616895 * H2_16_1 + -
                          0.499280016961099 * H2_17_1 + 0.490339344742002 * H2_18_1 + 0.178225816271424 * H2_2_1 + 0.0963681527679219 * H2_3_1 + 0.297379694453632 * H2_4_1 + -0.610309572541614 * H2_5_1 + -0.222662509776254 * H2_6_1 + -0.128553175629198 * H2_7_1 + 0.179773224932782 * H2_8_1 + -0.373788430670111 * H2_9_1), 2))))

        H1_16_1 = jmp.exp(-((0.5 * jmp.pow((0.171702863548417 + -0.341170532942289 * H2_1_1 + 0.205577489031212 * H2_10_1 + -0.353427134142654 * H2_11_1 + -0.235381774320074 * H2_12_1 + -0.370453494136813 * H2_13_1 + 0.89776076034959 * H2_14_1 + 0.207786964134416 * H2_15_1 + 0.185704121659094 * H2_16_1 +
                          0.112630225983953 * H2_17_1 + -0.0231604805001514 * H2_18_1 + 0.0656870076536465 * H2_2_1 + 0.561627872119082 * H2_3_1 + 0.0818586215098209 * H2_4_1 + -0.0481661519601953 * H2_5_1 + 0.0140184158304734 * H2_6_1 + 0.258109965957156 * H2_7_1 + 0.536078929879211 * H2_8_1 + 0.167305984355509 * H2_9_1), 2))))

        H1_17_1 = jmp.exp(-((0.5 * jmp.pow((-0.0603720775050909 + -0.444736795358491 * H2_1_1 + -0.335013139209679 * H2_10_1 + 0.805084629707911 * H2_11_1 + -0.354562852058018 * H2_12_1 + -0.265779729290472 * H2_13_1 + -1.38985260827843 * H2_14_1 + -0.310643815028569 * H2_15_1 + -0.432362669617564 * H2_16_1 +
                          0.458902425051997 * H2_17_1 + -0.214370492213427 * H2_18_1 + 0.369288125172578 * H2_2_1 + -0.371471883332261 * H2_3_1 + 0.669046569423987 * H2_4_1 + -0.0388510379431323 * H2_5_1 + -0.00594449291508687 * H2_6_1 + -0.102962416887087 * H2_7_1 + -0.153028443521115 * H2_8_1 + -0.114126323551371 * H2_9_1), 2))))

        H1_18_1 = jmp.exp(-((0.5 * jmp.pow((0.224511785131707 + 0.0188713119814545 * H2_1_1 + -0.354924406106125 * H2_10_1 + 0.0731443239035478 * H2_11_1 + -0.401813922443131 * H2_12_1 + 0.365035374525466 * H2_13_1 + -0.316230895825465 * H2_14_1 + 0.566827507894281 * H2_15_1 + 0.939039629118365 * H2_16_1 +
                          0.0173577317554743 * H2_17_1 + 0.275193272048105 * H2_18_1 + -0.43093736842368 * H2_2_1 + -0.00121405687279825 * H2_3_1 + 0.264543314567979 * H2_4_1 + -0.180897510005295 * H2_5_1 + 0.0292209734197501 * H2_6_1 + -0.725309701804353 * H2_7_1 + 0.219291624940775 * H2_8_1 + 0.520070676015583 * H2_9_1), 2))))

        predicted_egtm = 65.2339459255344 + -2.89868505284982 * H1_1_1 + -0.543707743088633 * H1_10_1 + 1.74657517975029 * H1_11_1 + 9.08389141436191 * H1_12_1 + -4.48284354211216 * H1_13_1 + -6.51560646518644 * H1_14_1 + -4.33939872274262 * H1_15_1 + -4.56793031866524 * H1_16_1 + \
            4.35410286408807 * H1_17_1 + -3.50740515112812 * H1_18_1 + 9.11771662466497 * H1_2_1 + -1.44473080879938 * H1_3_1 + 6.14001423476553 * H1_4_1 + - \
            6.6283227068117 * H1_5_1 + 5.90478699773599 * H1_6_1 + 1.50692210343086 * \
            H1_7_1 + -0.745493194176206 * H1_8_1 + 2.92093768918262 * H1_9_1

        self.EGTM_degC = predicted_egtm
        self.fan_CR -= 1
        self.core_CR -= 1
        self.lpt_CR -= 1
        self.cycles_since_maint = self.cycles_since_maint + 1

    def check_degrade_nn(self,
                    OAT_degC: float,
                    alt_ft: int,
                    runway_length_ft: int,
                    TOGW_lbs: int):

            cycles_since_maint = self.cycles_since_maint

            # REFERENCE
            H2_1 = tanh((174.164821787562 +
                        0.0150183700071807 *
                        OAT_degC +
                        0.000947143072086257 *
                        alt_ft +
                        0.0000423079257930463 *
                        TOGW_lbs +
                        -0.0151675872844966 *
                        runway_length_ft))

            H2_2 = tanh((1.01830492829757 +
                        0.0567232483844859 *
                        OAT_degC +
                        0.0000704466763794585 *
                        alt_ft + -
                        0.0000145053103233196 *
                        TOGW_lbs +
                        0.0000543367777941306 *
                        runway_length_ft))

            H2_3 = tanh((-2.27644562276078 +
                        0.015488175687018 *
                        OAT_degC +
                        0.0000778760831673512 *
                        alt_ft +
                        0.0000127003730027054 *
                        TOGW_lbs +
                        -0.0000069454345893263 *
                        runway_length_ft))

            H2_4 = tanh((47.0970249032349 +
                        0.0101091512130753 *
                        OAT_degC +
                        -0.000105290133280793 *
                        alt_ft +
                        0.0000143042262120981 *
                        TOGW_lbs +
                        -0.00409831577932796 *
                        runway_length_ft))

            H2_5 = 8.3275695007449 + \
                0.0286374794089978 * \
                OAT_degC + \
                0.000337088679082665 * \
                alt_ft + \
                0.0000073704792191387 * \
                TOGW_lbs + \
                -0.000971764515303416 * \
                runway_length_ft

            H2_6 = -11.8743758677331 +\
                0.0668068785427457 * \
                OAT_degC + \
                -0.00214856381165951 *\
                alt_ft + \
                0.0000189924865427877 * \
                TOGW_lbs +\
                0.000647997130014476 * \
                runway_length_ft

            H2_7 = -13.3795468783909 + \
                -0.00320566567716204 * \
                OAT_degC + \
                0.00179796955519473 *\
                alt_ft + \
                -0.0000246842497082961 * \
                TOGW_lbs + \
                0.0014433942820324 * \
                runway_length_ft

            H2_8 = -14.4774368396608 + \
                -0.0130214921834953 * \
                OAT_degC +\
                0.00330719487176896 * \
                alt_ft + - \
                0.0000012455519206328 * \
                TOGW_lbs + \
                0.00103585278621634 * \
                runway_length_ft

            H2_9 = jmp.exp(-((0.5 * jmp.pow((-4.88965465182652 +
                                            -0.0100065633335312 *
                                            OAT_degC +
                                            -0.000344349102456848 *
                                            alt_ft +
                                            0.0000047132830316258 *
                                            TOGW_lbs +
                                            0.000311174080599601 *
                                            runway_length_ft), 2))))

            H2_10 = jmp.exp(-((0.5 * jmp.pow((-11.2353984266547 +
                                            -0.0108351413636036 *
                                            OAT_degC +
                                            0.00110051814611241 *
                                            alt_ft +
                                            0.0000116558312962193 *
                                            TOGW_lbs +
                                            0.000965199915233237 *
                                            runway_length_ft), 2))))

            H2_11 = jmp.exp(-((0.5 * jmp.pow((40.5639191994154 +
                                            -0.00254452388757888 *
                                            OAT_degC +
                                            0.000229009546327252 *
                                            alt_ft +
                                            0.0000020639921729637 *
                                            TOGW_lbs +
                                            -0.00335664143024474 *
                                            runway_length_ft), 2))))

            H2_12 = jmp.exp(-((0.5 * jmp.pow((20.9985136934855 +
                                            -0.00559593937827498 *
                                            OAT_degC +
                                            -0.000425922153324789 *
                                            alt_ft +
                                            0.0000073481470450792 *
                                            TOGW_lbs +
                                            -0.00176787362649127 *
                                            runway_length_ft), 2))))

            H1_1 = tanh((0.851128637533044 +
                        -0.108299563589652 *
                        H2_1 +
                        1.64245520465694 *
                        H2_10 +
                        -0.284715902246175 *
                        H2_11 +
                        0.734356438045888 *
                        H2_12 +
                        0.306111381015951 *
                        H2_2 +
                        1.15235361931861 *
                        H2_3 +
                        0.325969194788733 *
                        H2_4 +
                        0.743184388679846 *
                        H2_5 +
                        -0.343302736090084 *
                        H2_6 +
                        1.76092072305976 *
                        H2_7 +
                        -1.20175686725659 *
                        H2_8 +
                        -1.78409325192986 *
                        H2_9))

            H1_2 = tanh((-0.0791822040188334 +
                        1.66421641209447 *
                        H2_1 +
                        8.9522319219804 *
                        H2_10 +
                        0.917476567984544 *
                        H2_11 +
                        -1.3154819485005 *
                        H2_12 +
                        0.771922544802388 *
                        H2_2 +
                        -0.0999427956362843 *
                        H2_3 +
                        -1.83700781947894 *
                        H2_4 +
                        -2.53089496277077 *
                        H2_5 +
                        0.560595163435119 *
                        H2_6 +
                        0.158792529267962 *
                        H2_7 +
                        1.21509148589036 *
                        H2_8 +
                        1.47916709245556 *
                        H2_9))

            H1_3 = tanh((-0.0601579460387387 +
                        -0.0184264656999116 *
                        H2_1 +
                        -3.01925094011184 *
                        H2_10 +
                        9.33937382993851 *
                        H2_11 +
                        3.39361965099569 *
                        H2_12 +
                        0.614893830043801 *
                        H2_2 + 0.927511197922047 *
                        H2_3 +
                        -0.295192658403999 *
                        H2_4 +
                        1.44199061311736 *
                        H2_5 +
                        -0.492863078769391 *
                        H2_6 +
                        2.29588484420714 *
                        H2_7 +
                        2.57888435588379 *
                        H2_8 +
                        -1.2711708964783 *
                        H2_9))

            H1_4 = tanh((0.812578770259727 +
                        0.607350271462214 *
                        H2_1 +
                        -2.41846116770632 *
                        H2_10 +
                        0.37621463301884 *
                        H2_11 +
                        1.61883936835252 *
                        H2_12 +
                        0.0303136804626097 *
                        H2_2 +
                        0.116824919770507 *
                        H2_3 +
                        -0.267984762850041 *
                        H2_4 +
                        1.36990489589426 *
                        H2_5 +
                        1.31706787216699 *
                        H2_6 +
                        -0.198169109109344 *
                        H2_7 +
                        0.737072289966816 *
                        H2_8 +
                        0.995867279263292 *
                        H2_9))

            H1_5 = -0.856424210781424 + \
                -0.991920825452957 * \
                H2_1 + \
                2.01329600233579 *\
                H2_10 + \
                1.63490294066566 *\
                H2_11 + \
                -1.04804673924758 *\
                H2_12 + \
                -2.84364828019787 * \
                H2_2 + \
                -0.81994541263742 *\
                H2_3 +\
                -0.650698173902487 *\
                H2_4 +\
                -1.12519082987031 *\
                H2_5 +\
                0.841303164436202 * \
                H2_6 + \
                -1.54057917089817 *\
                H2_7 + 2.3540270374098 *\
                H2_8 + \
                1.16184356906571 *\
                H2_9

            H1_6 = 3.73153627321292 + \
                -0.733534743235999 * \
                H2_1 +\
                -0.842805608706391 * \
                H2_10 + \
                1.03439389195872 * \
                H2_11 +\
                -0.778218112305387 *\
                H2_12 +\
                0.851639458813897 *\
                H2_2 +\
                -3.82555326745561 * \
                H2_3 +\
                1.06750437669271 *\
                H2_4 +\
                0.0139769097808124 *\
                H2_5 +\
                0.226994289201912 * \
                H2_6 +\
                -1.96321417947815 * \
                H2_7 +\
                0.516495639704889 * \
                H2_8 +\
                -0.254450117592212 *\
                H2_9

            H1_7 = -4.42109924217421 +\
                0.353080098643115 * \
                H2_1 + \
                1.17773336734786 * \
                H2_10 +\
                -1.35065842566458 *\
                H2_11 + \
                0.610192195165197 * \
                H2_12 + \
                -2.06965889558599 * \
                H2_2 +\
                6.12296124080088 * \
                H2_3 +\
                0.109611786505414 * \
                H2_4 + \
                -0.024498521882812 * \
                H2_5 +\
                0.270452407977642 * \
                H2_6 +\
                -1.06604504722132 * \
                H2_7 +\
                -0.821097310899443 *\
                H2_8 + \
                0.886383372866355 *\
                H2_9

            H1_8 = 1.17549338131375 + \
                1.24076735925444 * \
                H2_1 + \
                -1.75426598084629 *\
                H2_10 + \
                -0.293506856274672 *\
                H2_11 +\
                -0.986270258038301 *\
                H2_12 +\
                0.898205500560073 * \
                H2_2 +\
                -5.24661188556761 * \
                H2_3 + \
                0.502446722785196 * \
                H2_4 + \
                0.314957671669226 *\
                H2_5 +\
                1.19308628004163 * \
                H2_6 +\
                -2.22767828866015 * \
                H2_7 +\
                -0.54225204104445 *\
                H2_8 +\
                -2.60806817035206 *\
                H2_9

            H1_9 = jmp.exp(-((0.5 * jmp.pow((1.72275141037306 +
                                            -3.20746624322573 *
                                            H2_1 +
                                            -0.277360153564307 *
                                            H2_10 +
                                            0.679583317787098 *
                                            H2_11 +
                                            1.60979892163742 *
                                            H2_12 +
                                            3.74852891723103 *
                                            H2_2 +
                                            0.363933115514676 *
                                            H2_3 +
                                            2.12717822593958 *
                                            H2_4 +
                                            3.3801271657094 *
                                            H2_5 +
                                            -1.81173472033208 *
                                            H2_6 +
                                            -1.99694118966928 *
                                            H2_7 +
                                            -0.300158534622706 *
                                            H2_8 +
                                            -2.41674956621846 *
                                            H2_9), 2))))

            H1_10 = jmp.exp(-((0.5 * jmp.pow((-1.49708115498306 +
                                            -4.37560146763932 *
                                            H2_1 +
                                            -0.493201043435781 *
                                            H2_10 +
                                            -1.056108417308 *
                                            H2_11 +
                                            -0.68734030056216 *
                                            H2_12 +
                                            -0.97870840617636 *
                                            H2_2 +
                                            1.89136422553161 *
                                            H2_3 +
                                            4.35324680005191 *
                                            H2_4 +
                                            1.07547051493475 *
                                            H2_5 +
                                            0.608689534896784 *
                                            H2_6 +
                                            -1.40201205133433 *
                                            H2_7 +
                                            1.42320599744481 *
                                            H2_8 +
                                            6.3469894710242 *
                                            H2_9), 2))))

            H1_11 = jmp.exp(-((0.5 * jmp.pow((-4.34544834927136 +
                                            -4.7489574464523 *
                                            H2_1 +
                                            2.90439968365315 *
                                            H2_10 +
                                            -8.75068759006729 *
                                            H2_11 +
                                            2.27051058068487 *
                                            H2_12 +
                                            -0.664457566353004 *
                                            H2_2 + -4.04341841042835 *
                                            H2_3 +
                                            5.4741452306019 *
                                            H2_4 +
                                            2.33993676738096 *
                                            H2_5 +
                                            0.91851220105594 *
                                            H2_6 +
                                            -0.113124431487999 *
                                            H2_7 +
                                            0.596527550498576 *
                                            H2_8 +
                                            10.2083896518651 *
                                            H2_9), 2))))

            H1_12 = jmp.exp(-((0.5 * jmp.pow((0.337250157024277 +
                                            -1.00994998041862 *
                                            H2_1 +
                                            -0.594879893668468 *
                                            H2_10 +
                                            -1.7995459093753 *
                                            H2_11 +
                                            7.56059754290742 *
                                            H2_12 +
                                            -2.92469500628587 *
                                            H2_2 +
                                            1.42640261880607 *
                                            H2_3 +
                                            0.97368626307282 *
                                            H2_4 +
                                            2.87223769375986 *
                                            H2_5 +
                                            1.69172646458289 *
                                            H2_6 +
                                            -1.08159633356989 *
                                            H2_7 +
                                            1.64358833475413 *
                                            H2_8 +
                                            -1.49711821410107 *
                                            H2_9), 2))))

            n1_derate = 2.90057364503678 + \
                8.7852876107355 * \
                H1_1 +\
                -4.82738060076072 *\
                H1_10 + \
                9.73091182780243 * \
                H1_11 + \
                -3.21670694310469 *\
                H1_12 +\
                3.17762957603113 *\
                H1_2 + \
                3.43543452703158 *\
                H1_3 + \
                -0.459843481931124 *\
                H1_4 + \
                2.14445982666793 * \
                H1_5 +\
                1.2008015789921 * \
                H1_6 +\
                -4.31131218126633 *\
                H1_7 + \
                3.21290983891735 * \
                H1_8 +\
                -1.10152213041725 *\
                H1_9

            H2_1_1 = tanh((3.87097653746827 +
                        0.0280342577983546 *
                        OAT_degC +
                        0.000175881737374565 *
                        alt_ft +
                        -0.0000861962108971477 *
                        cycles_since_maint + -
                        0.0000305811977653951 *
                        TOGW_lbs +
                        0.0222902613874303 *
                        n1_derate +
                        0.0000461489488491519 *
                        runway_length_ft))

            H2_2_1 = tanh((7.10475872544167 +
                        -0.0447981502559777 *
                        OAT_degC +
                        -0.000199935716336436 *
                        alt_ft +
                        0.0000560871368327859 *
                        cycles_since_maint +
                        -0.0000351222370513881 *
                        TOGW_lbs +
                        0.0304871706147175 *
                        n1_derate +
                        -0.0000865707582502279 *
                        runway_length_ft))

            H2_3_1 = tanh((-3.33831661308874 +
                        0.010335967114618 *
                        OAT_degC +
                        0.0000175622645677883 *
                        alt_ft +
                        0.000237985057885064 *
                        cycles_since_maint +
                        0.0000053011529064076 *
                        TOGW_lbs +
                        0.000478469101390496 *
                        n1_derate +
                        0.000070132429936017 *
                        runway_length_ft))

            H2_4_1 = tanh((-5.93831738257207 +
                        0.0207877910019095 *
                        OAT_degC +
                        -0.000456700056833265 *
                        alt_ft +
                        -0.0000366663914083389 *
                        cycles_since_maint +
                        0.0000375361351772083 *
                        TOGW_lbs +
                        0.00497686230083288 *
                        n1_derate +
                        -0.0000187078359901544 *
                        runway_length_ft))

            H2_5_1 = tanh((2.28493756784204 +
                        -0.00587972701260045 *
                        OAT_degC +
                        0.000275248564100462 *
                        alt_ft +
                        0.0000247368905100449 *
                        cycles_since_maint +
                        0.0000023051461060682 *
                        TOGW_lbs +
                        -0.0153888755455835 *
                        n1_derate +
                        -0.000219163065070404 *
                        runway_length_ft))

            H2_6_1 = tanh((-0.731679059093489 +
                        -0.0153613396763209 *
                        OAT_degC +
                        0.000181504159614983 *
                        alt_ft +
                        0.0000235692144037898 *
                        cycles_since_maint +
                        -0.0000035753846507255 *
                        TOGW_lbs +
                        -0.0134449946343108 *
                        n1_derate +
                        0.000146193874028894 *
                        runway_length_ft))

            H2_7_1 = -0.0472633573023041 +\
                0.00565013378430554 * \
                OAT_degC + \
                -0.0000659615373059723 * \
                alt_ft + \
                -0.000328148143898803 * \
                cycles_since_maint + \
                0.0000099863663363883 *\
                TOGW_lbs + \
                0.0411549546193622 * \
                n1_derate + \
                0.0000205126965097397 * \
                runway_length_ft

            H2_8_1 = 8.58226892177825 + \
                -0.0108305165886741 * \
                OAT_degC + \
                -0.000407712267435268 *\
                alt_ft + \
                -0.000185445188792875 * \
                cycles_since_maint +\
                -0.0000213893456149655 * \
                TOGW_lbs + - \
                0.124752349969719 * \
                n1_derate + - \
                0.000203100460179 *\
                runway_length_ft

            H2_9_1 = 9.55741589336583 + \
                0.0673297524163601 * \
                OAT_degC + \
                0.000211672418931647 *\
                alt_ft +\
                0.000105637869399919 *\
                cycles_since_maint + - \
                0.0000634683546750456 *\
                TOGW_lbs + \
                0.0531619272400084 * \
                n1_derate + \
                -0.00013519032178452 * \
                runway_length_ft

            H2_10_1 = -0.910547572058839 +\
                0.0366254278842287 *\
                OAT_degC +\
                -0.000592303863120266 *\
                alt_ft + \
                -0.000138219946239369 *\
                cycles_since_maint + \
                0.0000057359517910135 *\
                TOGW_lbs +\
                0.0893782768152271 * \
                n1_derate + \
                -0.0000204294617808335 * \
                runway_length_ft

            H2_11_1 = 5.24147077575014 + \
                -0.110789239250119 * \
                OAT_degC +\
                0.000259179541466903 * \
                alt_ft + \
                -0.000134701631048161 * \
                cycles_since_maint + - \
                0.0000274694918821557 *\
                TOGW_lbs +\
                -0.00508048668237046 * \
                n1_derate +\
                0.000213419201418101 * \
                runway_length_ft

            H2_12_1 = -4.0486908953105 +\
                0.0563845697483131 *\
                OAT_degC + \
                0.000297325799578212 * \
                alt_ft + \
                -0.00014975033074655 * \
                cycles_since_maint + \
                0.0000031173777717818 *\
                TOGW_lbs + \
                -0.0566787155295164 * \
                n1_derate +\
                0.000220187902493184 * \
                runway_length_ft

            H2_13_1 = jmp.exp(-((0.5 * jmp.pow((3.82120884055762 +
                                                0.00847921769155168 *
                                                OAT_degC +
                                                -0.00219634131465559 *
                                                alt_ft +
                                                0.0000244311022339467 *
                                                cycles_since_maint +
                                                -0.000033916886542443 *
                                                TOGW_lbs +
                                                -0.067746977691975 *
                                                n1_derate +
                                                0.000398908540548498 *
                                                runway_length_ft), 2))))

            H2_14_1 = jmp.exp(-((0.5 * jmp.pow((5.23767544398985 +
                                                -0.147249652015216 *
                                                OAT_degC +
                                                -0.000601013957625873 *
                                                alt_ft +
                                                -0.0000206437518170176 *
                            cycles_since_maint +
                            -0.0000007675658957586 *
                            TOGW_lbs +
                            0.00590183110004262 *
                            n1_derate +
                            -0.0000187023694796093 *
                            runway_length_ft), 2))))

            H2_15_1 = jmp.exp(-((0.5 * jmp.pow((-11.1318585041753 +
                                                0.0628072613943432 *
                                                OAT_degC +
                                                0.000956597140157948 *
                                                alt_ft +
                                                0.0000222719459914324 *
                            cycles_since_maint +
                            0.0000174323914740985 *
                            TOGW_lbs +
                            0.0299389177256089 *
                            n1_derate +
                            0.000537965804031497 *
                            runway_length_ft), 2))))

            H2_16_1 = jmp.exp(-((0.5 * jmp.pow((-6.91825234546525 +
                                                -0.0361563994113747 *
                                                OAT_degC +
                                                -0.00104655809809396 *
                                                alt_ft +
                                                0.0000190104957682618 *
                            cycles_since_maint +
                                -0.0000054530738765793 *
                                TOGW_lbs +
                                -0.0135813583173871 *
                                n1_derate +
                                                0.000783610065901488 *
                                                runway_length_ft), 2))))

            H2_17_1 = jmp.exp(-((0.5 * jmp.pow((14.2603240010516 +
                                                -0.0555802738702679 *
                                                OAT_degC +
                                                0.000007778345400371 *
                                                alt_ft +
                                                0.0000145377240709288 *
                            cycles_since_maint +
                            -0.0000222040188324996 *
                                TOGW_lbs +
                                                -0.0274067204953017 *
                                                n1_derate +
                                                -0.000779830243675701 *
                                                runway_length_ft), 2))))

            H2_18_1 = jmp.exp(-((0.5 * jmp.pow((10.697932643954 +
                                                -0.00107397586335005 *
                                                OAT_degC +
                                                -0.000416484670637215 *
                                                alt_ft +
                                                0.0000134616497221374 *
                            cycles_since_maint +
                            0.0000046850703516259 *
                            TOGW_lbs +
                                0.0012229135386195 *
                                n1_derate +
                                                -0.000817728008195142 *
                                                runway_length_ft), 2))))

            H1_1_1 = tanh((-0.210296995267164 +
                        -0.0123033325511553 *
                        H2_1_1 +
                        -0.141778432234927 *
                        H2_10_1 +
                        -0.246042738513232 *
                        H2_11_1 +
                        0.139172173023996 *
                        H2_12_1 +
                        -0.0896226050116433 *
                        H2_13_1 +
                        -0.0760125594569647 *
                        H2_14_1 +
                        -0.0522394460036675 *
                        H2_15_1 +
                        0.0852430014120027 *
                        H2_16_1 +
                        0.0999636313387697 *
                        H2_17_1 +
                        -0.0875980804881452 *
                        H2_18_1 +
                        -0.0135624094303232 *
                        H2_2_1 +
                        0.0735152495333425 *
                        H2_3_1 +
                        0.115772601933675 *
                        H2_4_1 +
                        -0.0151690131842787 *
                        H2_5_1 +
                        0.0460631059234146 *
                        H2_6_1 +
                        -0.32771123426826 *
                        H2_7_1 +
                        -0.218092489969137 *
                        H2_8_1 +
                        -0.0105437199878345 *
                        H2_9_1))

            H1_2_1 = tanh((-0.265412885693325 +
                        -0.272507465310425 *
                        H2_1_1 +
                        -0.425496778421572 *
                        H2_10_1 +
                        -0.17943686157575 *
                        H2_11_1 +
                        0.599118251729463 *
                        H2_12_1 +
                        -0.00604757782682541 *
                        H2_13_1 +
                        -0.244015601387935 *
                        H2_14_1 +
                        0.0302831800719717 *
                        H2_15_1 +
                        -0.143055267421263 *
                        H2_16_1 +
                        -0.0104202598976084 *
                        H2_17_1 +
                        -0.0116225258412074 *
                        H2_18_1 +
                        0.582377736544845 *
                        H2_2_1 +
                        0.0692682086234926 *
                        H2_3_1 +
                        -0.0481676552607904 *
                        H2_4_1 +
                        -0.00889231358432505 *
                        H2_5_1 +
                        -0.0779190862792592 *
                        H2_6_1 +
                        -0.269457598189418 *
                        H2_7_1 +
                        0.523027306304918 *
                        H2_8_1 +
                        -0.450897148683874 *
                        H2_9_1))

            H1_3_1 = tanh((-0.00892597302447907 +
                        0.0291651802406506 *
                        H2_1_1 +
                        -0.038492223529273 *
                        H2_10_1 +
                        -0.0578701801136508 *
                        H2_11_1 +
                        -0.0217779401441155 *
                        H2_12_1 +
                        0.00900968387665714 *
                        H2_13_1 +
                        0.00112996864687473 *
                        H2_14_1 +
                        0.0163723212350254 *
                        H2_15_1 +
                        -0.0195571820904453 *
                        H2_16_1 +
                        -0.0160883791090023 *
                        H2_17_1 +
                        -0.0749498868310159 *
                        H2_18_1 +
                        0.03721784503171 *
                        H2_2_1 +
                        -0.0114236973221422 *
                        H2_3_1 +
                        -0.0242837644544957 *
                        H2_4_1 +
                        -0.0167358273326369 *
                        H2_5_1 +
                        0.0586190222019272 *
                        H2_6_1 +
                        -0.0471690434896757 *
                        H2_7_1 +
                        0.022675660886015 *
                        H2_8_1 +
                        0.103820210374688 *
                        H2_9_1))

            H1_4_1 = tanh((-0.114580648641034 +
                        -0.13485185465782 *
                        H2_1_1 +
                        0.097126085074532 *
                        H2_10_1 +
                        -0.214446446111474 *
                        H2_11_1 +
                        0.301308515100926 *
                        H2_12_1 +
                        -0.202391429404533 *
                        H2_13_1 +
                        -0.187310329142744 *
                        H2_14_1 +
                        0.395201440898779 *
                        H2_15_1 +
                        -0.306718535423445 *
                        H2_16_1 +
                        0.0216530384813532 *
                        H2_17_1 +
                        -0.382272725062622 *
                        H2_18_1 +
                        0.0270788317289997 *
                        H2_2_1 +
                        0.125557894916021 *
                        H2_3_1 +
                        0.0711419767716952 *
                        H2_4_1 +
                        -0.0621634774390786 *
                        H2_5_1 +
                        -0.127262160418274 *
                        H2_6_1 +
                        -0.040792557182331 *
                        H2_7_1 +
                        0.170560241001599 *
                        H2_8_1 +
                        0.254782095461612 *
                        H2_9_1))

            H1_5_1 = tanh((0.149433533114903 + 0.115778829172969 * H2_1_1 + 0.163671992847323 * H2_10_1 + -0.219644140691348 * H2_11_1 + 0.0332127644529657 * H2_12_1 + -0.100795523421998 * H2_13_1 + 0.214190523659682 * H2_14_1 + 0.0397669601073783 * H2_15_1 + -0.255509267496964 * H2_16_1 + 0.208761337183765 *
                        H2_17_1 + -0.437047397299986 * H2_18_1 + -0.45893078378474 * H2_2_1 + -0.0877701028010017 * H2_3_1 + 0.126467785310149 * H2_4_1 + -0.0776693027490542 * H2_5_1 + 0.0146301169537294 * H2_6_1 + 0.0317991351164752 * H2_7_1 + -0.266822207527166 * H2_8_1 + 0.310435635225406 * H2_9_1))

            H1_6_1 = tanh((-0.218751551024691 + 0.12183670470532 * H2_1_1 + -0.0803305382466221 * H2_10_1 + 0.130899885879507 * H2_11_1 + 0.234507271774673 * H2_12_1 + 0.0567113576993689 * H2_13_1 + 0.214000593018519 * H2_14_1 + 0.0830379814401789 * H2_15_1 + 0.173046229296445 * H2_16_1 + 0.0243844329119177 *
                        H2_17_1 + -0.14193133902221 * H2_18_1 + 0.0251017699419994 * H2_2_1 + 0.0371862589314573 * H2_3_1 + -0.024209415982397 * H2_4_1 + 0.0886675438695691 * H2_5_1 + -0.23163077812873 * H2_6_1 + 0.0180384730498385 * H2_7_1 + 0.280279901571398 * H2_8_1 + -0.0042647952515823 * H2_9_1))

            H1_7_1 = 0.12873364417657 + 0.0178332958236709 * H2_1_1 + 0.0249007119752557 * H2_10_1 + 0.0881388099460336 * H2_11_1 + -0.00119089464514913 * H2_12_1 + -0.0204003839158811 * H2_13_1 + 0.16671928208204 * H2_14_1 + -0.0173364177308842 * H2_15_1 + 0.0599976908526082 * H2_16_1 + - \
                0.0621853186858469 * H2_17_1 + 0.106005903362234 * H2_18_1 + -0.0632720266100166 * H2_2_1 + 0.122185015657916 * H2_3_1 + -0.09897557491244 * H2_4_1 + \
                0.0923933026347277 * H2_5_1 + -0.119655047059482 * H2_6_1 + 0.155566539093973 * \
                H2_7_1 + 0.0660745816501603 * H2_8_1 + -0.0378780794039895 * H2_9_1

            H1_8_1 = -0.0995529429080711 + -0.0449106356441903 * H2_1_1 + -0.0754378974680888 * H2_10_1 + -0.1186034409318 * H2_11_1 + 0.00806415892706063 * H2_12_1 + 0.0236553417236706 * H2_13_1 + -0.121425272951451 * H2_14_1 + -0.0478862986325866 * H2_15_1 + -0.0289059395489169 * H2_16_1 + \
                0.11160762080487 * H2_17_1 + -0.101439752420755 * H2_18_1 + 0.0937881163546217 * H2_2_1 + -0.104201463746245 * H2_3_1 + 0.0981180359453212 * H2_4_1 + - \
                0.143029005984706 * H2_5_1 + 0.148627563025411 * H2_6_1 + -0.135062142192853 * \
                H2_7_1 + -0.0509707822727457 * H2_8_1 + 0.00350288306333693 * H2_9_1

            H1_9_1 = 0.105716329070239 + 0.0627183647836477 * H2_1_1 + 0.0986704700972174 * H2_10_1 + 0.171266387451178 * H2_11_1 + -0.0491891383771212 * H2_12_1 + -0.00607393991070239 * H2_13_1 + 0.158053920467364 * H2_14_1 + 0.036139020368306 * H2_15_1 + 0.0873843224949578 * H2_16_1 + - \
                0.0817975084800823 * H2_17_1 + 0.162245907369364 * H2_18_1 + -0.118393581555658 * H2_2_1 + 0.199806605600871 * H2_3_1 + -0.137531847059336 * H2_4_1 + \
                0.17234926247131 * H2_5_1 + -0.236222925263099 * H2_6_1 + 0.198089120004223 * \
                H2_7_1 + 0.013751320507291 * H2_8_1 + -0.0439275980729064 * H2_9_1

            H1_10_1 = -0.0291719618274003 + 0.0505868900383836 * H2_1_1 + -0.0122943150942606 * H2_10_1 + -0.0384556377188337 * H2_11_1 + 0.0385681195513219 * H2_12_1 + -0.0154976373794634 * H2_13_1 + -0.00271892444808734 * H2_14_1 + -0.084028155285514 * H2_15_1 + -0.0635706254505327 * H2_16_1 + \
                0.00523118697936274 * H2_17_1 + 0.0140489184542031 * H2_18_1 + 0.0241569653519576 * H2_2_1 + -0.0269264159097883 * H2_3_1 + 0.0157157675531292 * H2_4_1 + - \
                0.0313997051417545 * H2_5_1 + 0.078524821368663 * H2_6_1 + 0.0187261485600662 * \
                H2_7_1 + 0.000212396213270248 * H2_8_1 + 0.0377660151469594 * H2_9_1

            H1_11_1 = -0.0317639567721912 + -0.0142656431468822 * H2_1_1 + -0.0389308413179387 * H2_10_1 + -0.0432051091197373 * H2_11_1 + 0.0295124860043135 * H2_12_1 + -0.0103909383300708 * H2_13_1 + -0.047467599395529 * H2_14_1 + 0.0255522291304017 * H2_15_1 + -0.0332397739086697 * H2_16_1 + - \
                0.0173508878521065 * H2_17_1 + -0.014810677069511 * H2_18_1 + 0.0278784447424492 * H2_2_1 + 0.00227262433615975 * H2_3_1 + 0.0143367692107757 * H2_4_1 + - \
                0.0254981085216542 * H2_5_1 + 0.0165124523472519 * H2_6_1 + -0.0147556352970393 * \
                H2_7_1 + -0.00906933251470102 * H2_8_1 + 0.0290565542839573 * H2_9_1

            H1_12_1 = 0.41464971790619 + 0.0313862648283103 * H2_1_1 + 0.289872676257492 * H2_10_1 + 0.427715972627544 * H2_11_1 + -0.141241192773735 * H2_12_1 + -0.0868386870438648 * H2_13_1 + 0.550704041235776 * H2_14_1 + 0.0531015380112605 * H2_15_1 + 0.324093103068797 * H2_16_1 + -0.269301082362803 * \
                H2_17_1 + 0.457891295199264 * H2_18_1 + -0.356608303002405 * H2_2_1 + 0.546926083649717 * H2_3_1 + -0.462343983231286 * H2_4_1 + \
                0.486848515031015 * H2_5_1 + -0.618903360325783 * H2_6_1 + 0.639106703436068 * \
                H2_7_1 + 0.157578016334705 * H2_8_1 + -0.0489049543075454 * H2_9_1

            H1_13_1 = jmp.exp(-((0.5 * jmp.pow((-0.218413131825808 +
                                                0.171856247192221 *
                                                H2_1_1 +
                                                0.178800033903368 *
                                                H2_10_1 +
                                                -0.192873420992058 *
                                                H2_11_1 +
                                                -0.140774150369086 *
                                                H2_12_1 +
                                                -0.166897695791908 *
                                                H2_13_1 +
                                                -0.156797745057997 *
                                                H2_14_1 +
                                                -0.444661586947161 *
                                                H2_15_1 +
                                                0.0318313983815137 *
                                                H2_16_1 +
                            0.236515648258599 *
                            H2_17_1 +
                                -0.18391655410077 *
                                                H2_18_1 +
                                                0.251798343747853 *
                                                H2_2_1 +
                                                -0.0360771307199465 *
                                                H2_3_1 +
                                                0.881160743973207 *
                                                H2_4_1 +
                                                -0.0959063499428145 *
                                                H2_5_1 +
                                                0.39235970593123 *
                                                H2_6_1 +
                                                0.333990007368626 *
                                                H2_7_1 +
                                                -0.630245843923043 *
                                                H2_8_1 +
                                                0.44056820528002 *
                                                H2_9_1), 2))))

            H1_14_1 = jmp.exp(-((0.5 * jmp.pow((0.527718073781037 +
                                                -0.325280480813892 *
                                                H2_1_1 +
                                                -0.135366620676507 * H2_10_1 + 0.616188662345391 * H2_11_1 + 0.368897451163304 * H2_12_1 + 1.84695883585929 * H2_13_1 + -0.809708823149772 * H2_14_1 + 0.244391747918192 * H2_15_1 + -1.04152196398353 * H2_16_1 +
                            1.02700212733067 * H2_17_1 + 1.21857347643319 * H2_18_1 + -0.308937092555415 * H2_2_1 + 0.833514116414842 * H2_3_1 + 0.212400064289121 * H2_4_1 + -0.471994696348804 * H2_5_1 + 0.0559786058423269 * H2_6_1 + 0.00935288505367367 * H2_7_1 + 0.102399271366053 * H2_8_1 + 0.317625959666211 * H2_9_1), 2))))

            H1_15_1 = jmp.exp(-((0.5 * jmp.pow((0.113639502637371 + -0.0407619390815003 * H2_1_1 + 0.782872910745383 * H2_10_1 + -0.00122573764205695 * H2_11_1 + -0.0199906115512351 * H2_12_1 + 0.43867597430897 * H2_13_1 + 0.70016104450024 * H2_14_1 + 0.187889291581387 * H2_15_1 + 0.638612063616895 * H2_16_1 + -
                            0.499280016961099 * H2_17_1 + 0.490339344742002 * H2_18_1 + 0.178225816271424 * H2_2_1 + 0.0963681527679219 * H2_3_1 + 0.297379694453632 * H2_4_1 + -0.610309572541614 * H2_5_1 + -0.222662509776254 * H2_6_1 + -0.128553175629198 * H2_7_1 + 0.179773224932782 * H2_8_1 + -0.373788430670111 * H2_9_1), 2))))

            H1_16_1 = jmp.exp(-((0.5 * jmp.pow((0.171702863548417 + -0.341170532942289 * H2_1_1 + 0.205577489031212 * H2_10_1 + -0.353427134142654 * H2_11_1 + -0.235381774320074 * H2_12_1 + -0.370453494136813 * H2_13_1 + 0.89776076034959 * H2_14_1 + 0.207786964134416 * H2_15_1 + 0.185704121659094 * H2_16_1 +
                            0.112630225983953 * H2_17_1 + -0.0231604805001514 * H2_18_1 + 0.0656870076536465 * H2_2_1 + 0.561627872119082 * H2_3_1 + 0.0818586215098209 * H2_4_1 + -0.0481661519601953 * H2_5_1 + 0.0140184158304734 * H2_6_1 + 0.258109965957156 * H2_7_1 + 0.536078929879211 * H2_8_1 + 0.167305984355509 * H2_9_1), 2))))

            H1_17_1 = jmp.exp(-((0.5 * jmp.pow((-0.0603720775050909 + -0.444736795358491 * H2_1_1 + -0.335013139209679 * H2_10_1 + 0.805084629707911 * H2_11_1 + -0.354562852058018 * H2_12_1 + -0.265779729290472 * H2_13_1 + -1.38985260827843 * H2_14_1 + -0.310643815028569 * H2_15_1 + -0.432362669617564 * H2_16_1 +
                            0.458902425051997 * H2_17_1 + -0.214370492213427 * H2_18_1 + 0.369288125172578 * H2_2_1 + -0.371471883332261 * H2_3_1 + 0.669046569423987 * H2_4_1 + -0.0388510379431323 * H2_5_1 + -0.00594449291508687 * H2_6_1 + -0.102962416887087 * H2_7_1 + -0.153028443521115 * H2_8_1 + -0.114126323551371 * H2_9_1), 2))))

            H1_18_1 = jmp.exp(-((0.5 * jmp.pow((0.224511785131707 + 0.0188713119814545 * H2_1_1 + -0.354924406106125 * H2_10_1 + 0.0731443239035478 * H2_11_1 + -0.401813922443131 * H2_12_1 + 0.365035374525466 * H2_13_1 + -0.316230895825465 * H2_14_1 + 0.566827507894281 * H2_15_1 + 0.939039629118365 * H2_16_1 +
                            0.0173577317554743 * H2_17_1 + 0.275193272048105 * H2_18_1 + -0.43093736842368 * H2_2_1 + -0.00121405687279825 * H2_3_1 + 0.264543314567979 * H2_4_1 + -0.180897510005295 * H2_5_1 + 0.0292209734197501 * H2_6_1 + -0.725309701804353 * H2_7_1 + 0.219291624940775 * H2_8_1 + 0.520070676015583 * H2_9_1), 2))))

            predicted_egtm = 65.2339459255344 + -2.89868505284982 * H1_1_1 + -0.543707743088633 * H1_10_1 + 1.74657517975029 * H1_11_1 + 9.08389141436191 * H1_12_1 + -4.48284354211216 * H1_13_1 + -6.51560646518644 * H1_14_1 + -4.33939872274262 * H1_15_1 + -4.56793031866524 * H1_16_1 + \
                4.35410286408807 * H1_17_1 + -3.50740515112812 * H1_18_1 + 9.11771662466497 * H1_2_1 + -1.44473080879938 * H1_3_1 + 6.14001423476553 * H1_4_1 + - \
                6.6283227068117 * H1_5_1 + 5.90478699773599 * H1_6_1 + 1.50692210343086 * \
                H1_7_1 + -0.745493194176206 * H1_8_1 + 2.92093768918262 * H1_9_1

            return predicted_egtm




class Engines(object):
    """
    Contains the function create_Engine, which
    creates a randomized engine
    """

    def __init__(self):
        return
    
    def create_Engine(esn:str)->Engine:

        engine = Engine(esn = esn,
                        fan_CR = random.randint(
                            cr_threshold,
                            fan_limit),
                        core_CR = random.randint(
                            cr_threshold,
                            core_limit),
                        lpt_CR = random.randint(
                            cr_threshold,
                            lpt_limit),
                        cycles_since_maint= random.randint(
                            new_eng_cycles,
                            old_eng_cycles),
                        )

        return engine


if __name__ == "__main__":
    # initialize random engine to test degredation to see if it's working
    
    engine = Engines.create_Engine("Bobby the Engine")

    OAT_degC = 25
    alt_ft = 2000
    runway_length_ft = 10000
    TOGW_lbs = 93000

    for i in range(1000):

        engine.degrade_nn(OAT_degC, alt_ft, runway_length_ft, TOGW_lbs)
        print("Engine serial number: " + engine.esn)
        print("Engine fan cycles remaining: ", engine.fan_CR)
        print("Engine core cycles remaining: ", engine.core_CR)
        print("Engine lpt cycles remaining: ", engine.lpt_CR)
        print("Engine cycles since maintenance: ", engine.cycles_since_maint)
        print("EGTM in deg C: ", engine.EGTM_degC)
        plt.figure(1)
        plt.plot(engine.cycles_since_maint, engine.EGTM_degC, '.b')
        plt.xlabel("Flight Cycles")
        plt.ylabel("Predicted EGTM (deg C)")
        plt.title("EGTM for " + engine.esn)
        plt.grid
plt.show()
