DEFINE('LPAD(S,N,C)') :(LPAD_END) LPAD * OUTPUT = " S = " S * OUTPUT = " N = " N * OUTPUT = " C = " C W = CONVERT(S,"STRING") * OUTPUT = " W = " W LPAD = GE(SIZE(W),N) W :S(RETURN) C = IDENT(C) ' ' LPAD = DUPL(C, N - SIZE(W)) W :(RETURN) LPAD_END DEFINE('ABS(N)') :(ABS_END) ABS ABS = LT(N,0.0) (0.0 - N) :s(RETURN) ABS = N :(RETURN) ABS_END TRACE('Predicted_Glucose','VALUE') TRACE('ksteps','VALUE') TRACE('factor1','VALUE') TRACE('C_Kstps','VALUE') TRACE('delta_ksteps','VALUE') &TRACE = 0 datechar = "0123456789/" INPUT('recommended',3,128,'recommended.txt') recommended_ksteps = recommended recommended_fat = recommended recommended_carb = recommended recommended_prot = recommended recommended_fiber = recommended recommended_sugar = recommended recommended_saturated = recommended recommended_carb_other = recommended_carb - recommended_fiber - recommended_sugar recommended_fat_other = recommended_fat - recommended_saturated INPUT('config',8,128,'conf.txt') order = config dummy1 = config dummy2 = config factor1 = config factor2 = config result_file = config INPUT('results_cross',2,128,result_file) C_Kstps = results_cross C_Fat_Other = results_cross C_Carb_Other = results_cross C_Protein =results_cross C_Fiber = results_cross C_Sugar = results_cross C_Saturated = results_cross LE(order,1) :s(DO_1A) C2_Kstps = results_cross C2_Fat_Other =results_cross C2_Carb_Other = results_cross C2_Protein = results_cross C2_Fiber = results_cross C2_Sugar = results_cross C2_Saturated = results_cross LE(order,2) :s(DO_1A) C2_ksteps_fat_other = results_cross C2_carb_other_fat_other = results_cross C2_protein_fat_other = results_cross C2_fiber_fat_other = results_cross C2_sugar_fat_other = results_cross C2_saturated_fat_other = results_cross C2_ksteps_carb_other = results_cross C2_protein_carb_other = results_cross C2_fiber_carb_other = results_cross C2_sugar_carb_other = results_cross C2_saturated_carb_other = results_cross C2_ksteps_protein = results_cross C2_fiber_protein = results_cross C2_sugar_protein = results_cross C2_saturated_protein = results_cross C2_ksteps_fiber = results_cross C2_sugar_fiber = results_cross C2_saturated_fiber = results_cross C2_ksteps_sugar = results_cross C2_saturated_sugar = results_cross C2_ksteps_saturated = results_cross DO_1A DEFINE('LEFT(str,le)','leftentry') echo = 0 dig = "0123456789." maxeqs = 1000 eq = ARRAY(maxeqs) eqno = 1 TITLE = LPAD('Glucose',24,' ') TITLE = TITLE LPAD('Prediction',24,' ') TITLE = TITLE LPAD('Previous',24,' ') TITLE = TITLE LPAD('Error',24,' ') TITLE = TITLE LPAD('Delta',24,' ') TITLE = TITLE LPAD('Percent Error (want small)',34,' ') TITLE = TITLE LPAD('Percent Delta',24,' ') TITLE = TITLE LPAD('How Good (want negative)',34,' ') OUTPUT = TITLE TOP LINE = INPUT :F(END) LINE SPAN(datechar) . occurred ARB . part1 RPOS(0) :f(TOP) part1 SPAN(' \t') SPAN(dig) . glucose ARB . part2 RPOS(0) part2 SPAN(' \t') SPAN(dig) . pglucose ARB . part3 RPOS(0) part3 SPAN(' \t') SPAN(dig) . cal ARB . part4 RPOS(0) part4 SPAN(' \t') SPAN(dig) . ksteps ARB . part5 RPOS(0) part5 SPAN(' \t') SPAN(dig) . fat ARB . part6 RPOS(0) part6 SPAN(' \t') SPAN(dig) . carb ARB . part7 RPOS(0) part7 SPAN(' \t') SPAN(dig) . prot ARB . part8 RPOS(0) part8 SPAN(' \t') SPAN(dig) . fiber ARB . part9 RPOS(0) part9 SPAN(' \t') SPAN(dig) . sugar ARB . part10 RPOS(0) part10 SPAN(' \t') SPAN(dig) . saturated ARB RPOS(0) * convert character to number glucose = glucose + 0.0 pglucose = pglucose + 0.0 cal = cal + 0.0 ksteps = ksteps + 0.0 fat = fat + 0.0 carb = carb + 0.0 prot = prot + 0.0 fiber = fiber + 0.0 sugar = sugar + 0.0 saturated = saturated + 0.0 carb_other = carb - fiber - sugar fat_other = fat - saturated delta_ksteps = (ksteps - recommended_ksteps) / recommended_ksteps / recommended_ksteps delta_fat = (fat - recommended_fat) / recommended_fat / recommended_fat delta_carb = (carb - recommended_carb) / recommended_carb / recommended_carb / recommended_carb delta_prot = (prot - recommended_prot) / recommended_prot / recommended_prot delta_fiber = (fiber - recommended_fiber) / recommended_fiber / recommended_fiber delta_sugar = (sugar - recommended_sugar) / recommended_sugar / recommended_sugar delta_saturated = (saturated - recommended_saturated) / recommended_saturated / recommended_saturated delta_carb_other = (carb_other - recommended_carb_other) / recommended_carb_other / recommended_carb_other delta_fat_other = (fat_other - recommended_fat_other) / recommended_fat_other / recommended_fat_other LT(echo, 1) :s(skip) OUTPUT = "#" "RECOMMENDED FOLLOW" OUTPUT = "#" "K steps = " recommended_ksteps OUTPUT = "#" "Fat = " recommended_fat OUTPUT = "#" "Carb = " recommended_carb OUTPUT = "#" "Protein = " recommended_prot OUTPUT = "#" "Fiber = " fiber recommended_fiber OUTPUT = "#" "Sugar = " recommended_sugar OUTPUT = "#" "Saturated Fat = " recommended_saturated OUTPUT = "#" "Other Carb = " recommended_carb_other OUTPUT = "#" "Other Fat = " recommended_fat_other OUTPUT = "# " LINE OUTPUT = "#" "VALUES FOLLOW" OUTPUT = "#" "Date = " occurred OUTPUT = "#" "Glucose = " glucose OUTPUT = "#" "Previous Glucose = " pglucose OUTPUT = "#" "Calories = " cal OUTPUT = "#" "K steps = " ksteps OUTPUT = "#" "Fat = " fat OUTPUT = "#" "Carb = " carb OUTPUT = "#" "Protein = " prot OUTPUT = "#" "Fiber = " fiber OUTPUT = "#" "Sugar = " sugar OUTPUT = "#" "Saturated Fat = " saturated OUTPUT = "#" "Other Fat = " fat_other OUTPUT = "#" "Other Carb = " carb_other OUTPUT = "#" "DELTAS FOLLOW" OUTPUT = "# " LINE * OUTPUT = "#" "Date = " occurred * OUTPUT = "#" "Glucose = " delta_glucose * OUTPUT = "#" "Previous Glucose = " pglucose * OUTPUT = "#" "Calories = " cal OUTPUT = "#" "K steps = " delta_ksteps OUTPUT = "#" "Fat = " delta_fat OUTPUT = "#" "Carb = " delta_carb OUTPUT = "#" "Protein = " delta_prot OUTPUT = "#" "Fiber = " delta_fiber OUTPUT = "#" "Sugar = " delta_sugar OUTPUT = "#" "Saturated Fat = " delta_saturated OUTPUT = "#" "Other Fat = " delta_fat_other OUTPUT = "#" "Other Carb = " delta_carb_other SKIP Predicted_Glucose = pglucose Predicted_Glucose = Predicted_Glucose + factor1 * C_Kstps * delta_ksteps Predicted_Glucose = Predicted_Glucose + factor1 * C_Fat_Other * delta_fat_other Predicted_Glucose = Predicted_Glucose + factor1 * C_Carb_Other * delta_carb_other Predicted_Glucose = Predicted_Glucose + factor1 * C_Protein * delta_prot Predicted_Glucose = Predicted_Glucose + factor1 * C_Fiber * delta_fiber Predicted_Glucose = Predicted_Glucose + factor1 * C_Sugar * sugar Predicted_Glucose = Predicted_Glucose + factor1 * C_Saturated * saturated LE(order, 1) :s(DO_1B) Predicted_Glucose = Predicted_Glucose + factor2 * C2_Kstps * delta_ksteps * delta_ksteps Predicted_Glucose = Predicted_Glucose + factor2 * C2_Fat_Other * delta_fat_other * delta_fat_other Predicted_Glucose = Predicted_Glucose + factor2 * C2_Carb_Other * delta_carb_other * delta_carb_other Predicted_Glucose = Predicted_Glucose + factor2 * C2_Protein * delta_prot * delta_prot Predicted_Glucose = Predicted_Glucose + factor2 * C2_Fiber * delta_fiber * delta_fiber Predicted_Glucose = Predicted_Glucose + factor2 * C2_Sugar * sugar * sugar Predicted_Glucose = Predicted_Glucose + factor2 * C2_Saturated * saturated * saturated LE(order, 2) :s(DO_1B) Predicted_Glucose = Predicted_glucose + factor2 * C2ksteps_fat_other * delta_ksteps * delta_fat_other Predicted_Glucose = Predicted_glucose + factor2 * C2_carb_other_fat_other * delta_carb_other * delta_fat_other Predicted_Glucose = Predicted_glucose + factor2 * C2_protein_fat_other * delta_prot * delta_fat_other Predicted_Glucose = Predicted_glucose + factor2 * C2_fiber_fat_other * delta_fiber * delta_fat_other Predicted_Glucose = Predicted_glucose + factor2 * C2_sugar_fat_other * sugar * delta_fat_other Predicted_Glucose = Predicted_glucose + factor2 * C2_saturated_fat_other * saturated * delta_fat_other Predicted_Glucose = Predicted_glucose + factor2 * C2_ksteps_carb_other * delta_ksteps * delta_carb_other Predicted_Glucose = Predicted_glucose + factor2 * C2_protein_carb_other * delta_prot * delta_carb_other Predicted_Glucose = Predicted_glucose + factor2 * C2_fiber_carb_other * delta_fiber * delta_carb_other Predicted_Glucose = Predicted_glucose + factor2 * C2_sugar_carb_other * delta_sugar * delta_carb_other Predicted_Glucose = Predicted_glucose + factor2 * C2_saturated_carb_other * saturated * delta_carb_other Predicted_Glucose = Predicted_glucose + factor2 * C2_ksteps_protein * delta_ksteps * delta_prot Predicted_Glucose = Predicted_glucose + factor2 * C2_fiber_protein * delta_fiber * delta_prot Predicted_Glucose = Predicted_glucose + factor2 * C2_sugar_protein * delta_sugar * delta_prot Predicted_Glucose = Predicted_glucose + factor2 * C2_saturated_protein * delta_saturated * delta_prot Predicted_Glucose = Predicted_glucose + factor2 * C2_ksteps_fiber * delta_ksteps * delta_fiber Predicted_Glucose = Predicted_glucose + factor2 * C2_sugar_fiber * delta_sugar * delta_fiber Predicted_Glucose = Predicted_glucose + factor2 * C2_saturated_fiber * delta_saturated * delta_fiber Predicted_Glucose = Predicted_glucose + factor2 * C2_ksteps_sugar * delta_ksteps * delta_sugar Predicted_Glucose = Predicted_glucose + factor2 * C2_saturated_sugar * delta_saturated * delta_sugar Predicted_Glucose = Predicted_glucose + factor2 * C2_ksteps_saturated * delta_ksteps * delta_saturated DO_1B Error = ABS(Predicted_Glucose - glucose) Perc_err = ABS(error * 100.0) / glucose delta_glucose =ABS(pglucose - glucose) Perc_delta = (delta_glucose * 100.0) / glucose * want next < 0 How_good = error - delta_glucose Lineout = LPAD(glucose,24,' ') Lineout = Lineout LPAD(Predicted_Glucose, 24, ' ') Lineout = Lineout LPAD(pglucose,24,' ') Lineout = Lineout LPAD(Error, 24, ' ') Lineout = Lineout LPAD(delta_glucose, 24, ' ') Lineout = Lineout LPAD(Perc_err, 34, ' ') Lineout = Lineout LPAD(Perc_delta, 24, ' ') Lineout = Lineout LPAD(how_good, 34, ' ') OUTPUT = Lineout :(TOP) leftentry str = str + 0.000001 str FENCE len(le) . left_wrk left = ' ' left_wrk ' ' :(RETURN) END