text:
using JuMP, EAGO

                     m = Model()

                     EAGO.register_eago_operators!(m)

                     @variable(m, -1 <= x[i=1:5] <= 1)

                     @variable(m, -53.467800048111016 <= q <= 50.665869089598125)

                     add_NL_constraint(m, :(1/(1 + exp(-(-0.14052056007525238 + -0.5593120910347902*1/(1 + exp(-(0.7927050633346799 + -0.9855209344073468*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8618242155643285*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.1409847014129051*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8981625305472791*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + -0.17714759684008552*1/(1 + exp(-(-0.6180581651393844 + 0.5051816616434088*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.300474118407668*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.9746449193496836*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.5011252416621814*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + -0.8034040228386923*1/(1 + exp(-(0.8979118028491286 + 0.6794924903988093*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.8327554381235851*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.9067656866208256*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.9508098734081298*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + 0.8830918026414509*1/(1 + exp(-(-0.664219788116319 + -0.6624649067900212*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.3925221054786987*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8696160844053109*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.357347274050821*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))))))))) + 1/(1 + exp(-(-0.9657657813458713 + 0.6555921464493895*1/(1 + exp(-(0.7927050633346799 + -0.9855209344073468*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8618242155643285*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.1409847014129051*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8981625305472791*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + -0.8721739939427047*1/(1 + exp(-(-0.6180581651393844 + 0.5051816616434088*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.300474118407668*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.9746449193496836*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.5011252416621814*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + 0.2771767659228326*1/(1 + exp(-(0.8979118028491286 + 0.6794924903988093*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.8327554381235851*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.9067656866208256*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.9508098734081298*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + -0.3272615516465871*1/(1 + exp(-(-0.664219788116319 + -0.6624649067900212*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.3925221054786987*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8696160844053109*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.357347274050821*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))))))))) + 1/(1 + exp(-(0.1449115541174284 + 0.09677925519094499*1/(1 + exp(-(0.7927050633346799 + -0.9855209344073468*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8618242155643285*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.1409847014129051*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8981625305472791*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + -0.7242562051573604*1/(1 + exp(-(-0.6180581651393844 + 0.5051816616434088*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.300474118407668*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.9746449193496836*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.5011252416621814*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + -0.5148279577072672*1/(1 + exp(-(0.8979118028491286 + 0.6794924903988093*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.8327554381235851*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.9067656866208256*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.9508098734081298*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + 0.31101299363436574*1/(1 + exp(-(-0.664219788116319 + -0.6624649067900212*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.3925221054786987*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8696160844053109*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.357347274050821*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))))))))) + 1/(1 + exp(-(-0.29157998590300416 + 0.37951557973783334*1/(1 + exp(-(0.7927050633346799 + -0.9855209344073468*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8618242155643285*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.1409847014129051*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8981625305472791*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + 0.5044820689237324*1/(1 + exp(-(-0.6180581651393844 + 0.5051816616434088*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.300474118407668*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.9746449193496836*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.5011252416621814*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + 0.4692646156920386*1/(1 + exp(-(0.8979118028491286 + 0.6794924903988093*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.8327554381235851*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.9067656866208256*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.9508098734081298*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5])))))))))) + -0.6236220471665241*1/(1 + exp(-(-0.664219788116319 + -0.6624649067900212*1/(1 + exp(-(-0.5279345513587295 + 0.26674570975926315*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.6014540451740125*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.7842020578742437*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.7348995303901047*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + 0.3925221054786987*1/(1 + exp(-(-0.9736042039183683 + -0.3730380073565449*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + -0.6111131700945078*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.6070668283472709*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + 0.602250903818204*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.8696160844053109*1/(1 + exp(-(-0.7008144662498323 + 0.1168473746120049*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.28223204928638745*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.1750913505933096*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.6765062198397387*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))) + -0.357347274050821*1/(1 + exp(-(0.7932740070802415 + 0.6457743599334909*1/(1 + exp(-(-0.7911508587829115 + -0.06506911132939441*$(x[1]) + -0.852429148445272*$(x[2]) + 0.9902340539920638*$(x[3]) + -0.5325045469076417*$(x[4]) + 0.16346424911659252*$(x[5])))) + 0.13450970941280982*1/(1 + exp(-(-0.31894961218704987 + -0.02324224975324851*$(x[1]) + -0.016870940285415248*$(x[2]) + 0.446182370860321*$(x[3]) + -0.9288490609590947*$(x[4]) + 0.29295311736763896*$(x[5])))) + -0.4617332497282156*1/(1 + exp(-(-0.4972259981592049 + -0.8938534018236086*$(x[1]) + 0.008380370033680418*$(x[2]) + -0.18784778862206242*$(x[3]) + 0.20554715210351482*$(x[4]) + 0.7932560928666454*$(x[5])))) + -0.2655397829444155*1/(1 + exp(-(-0.6657792028971241 + -0.5409713712241491*$(x[1]) + 0.49245843557230895*$(x[2]) + 0.7906244992303582*$(x[3]) + 0.4705847767166267*$(x[4]) + -0.3481500575812202*$(x[5]))))))))))))) - $q <= 0.0))

                     @objective(m, Min, q)

                     return m

max_stars_repo_name: PSORLab/RSActivationFunctions

max_issues_repo_name: PSORLab/RSActivationFunctions

max_forks_repo_name: PSORLab/RSActivationFunctions


text:
#################### Discrete Gibbs Sampler ####################

#################### Types and Constructors ####################

const DGSUnivariateDistribution =
          Union{Bernoulli, Binomial, Categorical, DiscreteUniform,
                Hypergeometric, NoncentralHypergeometric}

const DSForm = Union{Function, Vector{Float64}}

mutable struct DSTune{F<:DSForm} <: SamplerTune
  mass::Union{F, Missing}
  support::Matrix{Real}

  DSTune{F}() where {F<:DSForm} = new{F}()

  DSTune{F}(x::Vector, support::AbstractMatrix) where {F<:DSForm} =
    new{F}(missing, support)

  DSTune{F}(x::Vector, support::AbstractMatrix, mass::Function) where {F<:DSForm} = new{F}(mass, support)
end

const DGSVariate = SamplerVariate{DSTune{Function}}
const DiscreteVariate = SamplerVariate{DSTune{Vector{Float64}}}

validate(v::DGSVariate) = validate(v, v.tune.support)

function validate(v::DiscreteVariate)
  validate(v, v.tune.support)
  validate(v, v.tune.support, v.tune.mass)
end

function validate(v::SamplerVariate{DSTune{F}}, support::Matrix) where {F<:DSForm}
  n = length(v)
  size(support, 1) == n ||
    throw(ArgumentError("size(support, 1) differs from variate length $n"))
  v
end

validate(v::DiscreteVariate, support::Matrix, mass::Union{Vector{Float64}, Missing}) =
  isa(mass, Missing) ? v : validate(v, support, mass)

function validate(v::DiscreteVariate, support::Matrix, mass::Vector{Float64})
  n = length(mass)
  size(support, 2) == n ||
    throw(ArgumentError("size(support, 2) differs from mass length $n"))
  v
end

#################### Sampler Constructor ####################
"""
    DGS(params::ElementOrVector{Symbol})

Construct a `Sampler` object for which DGS sampling is to be applied separately
to each of the supplied parameters. Parameters are assumed to have discrete
univariate distributions with finite supports.

Returns a `Sampler{DSTune{Function}}` type object.

* `params`: stochastic node(s) to be updated with the sampler.

"""
function DGS(params::ElementOrVector{Symbol})
  params = asvec(params)
  samplerfx = function(model::Model, block::Integer)
    s = model.samplers[block]
    local node, x
    for key in params
      node = model[key]
      x = unlist(node)

      sim = function(i::Integer, d::DGSUnivariateDistribution, mass::Function)
        v = DGSVariate([x[i]], support(d)')
        sample!(v, mass)
        x[i] = v[1]
        relist!(model, x, key)
      end

      mass = function(d::DGSUnivariateDistribution, v::AbstractVector,
                      i::Integer)
        x[i] = value = v[1]
        relist!(model, x, key)
        exp(logpdf(d, value) + logpdf(model, node.targets))
      end

      DGS_sub!(node.distr, sim, mass)
    end
    nothing
  end
  Sampler(params, samplerfx, DSTune{Function}())
end

function DGS_sub!(d::UnivariateDistribution, sim::Function, mass::Function)
  sim(1, d, v -> mass(d, v, 1))
end

function DGS_sub!(D::Array{UnivariateDistribution}, sim::Function,
                  mass::Function)
  for i in 1:length(D)
    d = D[i]
    sim(i, d, v -> mass(d, v, i))
  end
end

function DGS_sub!(d, sim::Function, mass::Function)
  throw(ArgumentError("unsupported distribution structure $(typeof(d))"))
end

#################### Sampling Functions ####################

sample!(v::SamplerVariate{DSTune{F}}) where {F<:DSForm} = sample!(v, v.tune.mass)

"""
    sample!(v::DGSVariate, mass::Function)

Draw one sample directly from a target probability mass function. Parameters
are assumed to have discrete and finite support.

Returns `v` updated with simulated values and associated tuning parameters.
"""
function sample!(v::DGSVariate, mass::Function)
  tune = v.tune
  n = size(tune.support, 2)
  probs = Vector{Float64}(undef, n)
  psum = 0.0
  for i in 1:n
    value = mass(tune.support[:, i])
    probs[i] = value
    psum += value
  end
  if psum > 0
    probs /= psum
  else
    probs[:] .= 1 / n
  end
  v[:] = tune.support[:, rand(Categorical(probs))]
  v
end

"""
    sample!(v::DiscreteVariate, mass::Vector{Float64})

Draw one sample directly from a target probability mass function. Parameters
are assumed to have discrete and finite support.

Returns `v` updated with simulated values and associated tuning parameters.
"""
function sample!(v::DiscreteVariate, mass::Vector{Float64})
  validate(v, v.tune.support, mass)
  v[:] = v.tune.support[:, rand(Categorical(mass))]
  v
end

ext: jl


text:
typedict(x) = Dict(fn=>getfield(x, fn) for fn in fieldnames(typeof(x)))

function saveinput(input, filename)
    filename = filename[end-4:end] == ".json" ? filename : filename * ".json"
    inputdict = typedict(input)
    open(filename, "w") do io
        JSON.print(io, inputdict, 4)
    end
end

function loadinput(inputtype, filename)
    inputdict = JSON.parsefile(filename, dicttype=Dict{Symbol, Any})
    loadinput(inputtype, inputdict::Dict)
end

function loadinput(inputtype, inputdict::Dict)
    return inputtype(;inputdict...)
end

function saveoutput(population, output, outputdir, seed, id, rng::AbstractRNG=Random.GLOBAL_RNG)
    outputdir = outputdir[end] == '/' ? outputdir : outputdir * '/'
    mkpath(outputdir)

    if haskeytrue(output, :compare_sampled_modules)
        save_sampled_module_compare(population, output[:nsample], outputdir, id, rng)
    end
    if haskeytrue(output, :pfd_matrix)
        save_pfd_matrix(population, outputdir, id)
    end
    if haskeytrue(output, :sharedfixedmuts)
        save_sharedfixedmuts(population, outputdir, id)
    end
    if haskeytrue(output, :moduleancestory)
        save_moduleancestory(population, outputdir, id)
    end
    save_other_population_data(population, output, outputdir, id)

end

haskeytrue(output, key) = haskey(output, key) && output[key]

function save_moduleancestory(population, outputdir, id)
    open(outputdir*"moduleancestory.txt", "w") do io
        for moduletracker in population
            write(io, "$(moduletracker.parentid)    $(moduletracker.id)    $(moduletracker.tvec[1])\n")
        end
    end
end

function save_sampled_module_compare(population, nsample, outputdir, id, rng)
    pairwisefixeddiff, sharedfixedmuts = sampledmoduledata(population, nsample, rng)
        open(outputdir*"pairwisefixeddiff_$id.txt", "w") do io
            writedlm(io, zip(keys(pairwisefixeddiff), values(pairwisefixeddiff)))
        end
        open(outputdir*"sharedfixedmuts_$id.txt", "w") do io
            writedlm(io, zip(keys(sharedfixedmuts), values(sharedfixedmuts)))
        end
end

function sampledmoduledata(population, nsample, rng)
    samplemodules = sample(rng, 1:length(population), nsample, replace=false)
    clonalmuts = clonal_mutation_ids(population, samplemodules)
    pairwisefixeddiff = pairwise_fixed_differences(clonalmuts)
    sharedfixedmuts = shared_fixed_mutations(clonalmuts)
    return pairwisefixeddiff, sharedfixedmuts
end

function save_pfd_matrix(population, outputdir, id)
    pfd = pairwise_fixed_differences_matrix(population, diagonals=true)
    open(outputdir*"pfdmatrix_$id.txt", "w") do io
        writedlm(io, pfd)
    end
end

function save_sharedfixedmuts(population, outputdir, id)
    sharedfixedmuts = shared_fixed_mutations(population)
    open(outputdir*"sharedfixedmutsall_$i.txt", "w") do io
        writedlm(io, sharedfixedmuts)
    end
end

function save_other_population_data(population, output, outputdir, id)
    outputdict = Dict()
    if output[:finalmodules]
        outputdict[:finalmodules] = length(population)
    end
    if output[:finalage]
        outputdict[:finalage] = age(population)
    end
    if output[:mutation_stats]
        outputdict[:mutations_mean], outputdict[:mutations_var] =
            average_mutations(population, true)
    end
    if output[:pfd_stats]
        pfd_mean, pfd_var, fixedmutations_mean, fixedmutations_var =
            pairwise_fixed_differences_statistics(population, clonal=true)
        outputdict[:pfd_mean] = pfd_mean
        outputdict[:pfd_var] = pfd_var
        outputdict[:fixedmutations_mean] = fixed_mutations_mean
        outputdict[:fixedmutations_var] = fixed_mutations_var
    end
    open(outputdir*"summarydata_$id.json", "w") do io
        JSON.print(io, outputdict, 4)
    end
end


text:
using GLFW

glfwDll = GLFW.lib #should throw error if not exists
glfwLibs = abspath(GLFW.lib,"../")
glfwIncludes = abspath(glfwLibs,"../","include/")

!isdir(glfwIncludes) && error("$glfwIncludes is not found, ensure it is an absolute path.")
!isdir(glfwLibs) && error("$glfwLibs is not found, ensure it is an absolute path.")

max_stars_repo_name: Gilga/JuliaOpenGL

max_issues_repo_name: Gilga/JuliaOpenGL

max_forks_repo_name: Gilga/JuliaOpenGL


text:
################################################################################
# GLOBAL SHOCKS: Data maker
# I will cut every dataset at 2018Q4
# Written by: Christian Velasquez
# velasqcb@bc.edu
################################################################################
function GSDataLoader(dir1)

if ~isdir(".//Figures")   mkdir("Figures") end
# ------------------------------------------------------------------------------
# Quaterly labels
# ------------------------------------------------------------------------------
qlabel = Array{String,2}(undef, 84, 1)
for i = 1:84
    year = string(1998 + div(i - 1, 4))
    quaterly = "Q" * string(mod(i - 1, 4) + 1)
    qlabel[i] = year * quaterly
end

#= ------------------------------------------------------------------------
	[1.1] GDP G20
	link:		https://data.oecd.org/gdp/quarterly-gdp.htm#indicator-chart
	We select volume index
 The quaterly data starts at `1998Q1`
 ------------------------------------------------------------------------ =#
g20 = DataFrame(CSV.File("$dir1/DP_LIVE_14072020212217545.csv"));
g20 = g20[g20.LOCATION.=="G-20", :];
g20 = g20[1:end-4, [1, 6, 7]];
g20 = log.(g20[:,3])
#= ------------------------------------------------------------------------
 	[1.2] BAA spread
	link: https://fred.stlouisfed.org/series/BAAFFM
	serie: Moody's Seasoned Baa Corporate Bond Minus Federal Funds Rate
	rename to FRED and save in xlsx format
 The quaterly data starts at `1998Q1`
 ------------------------------------------------------------------------ =#
y = DataFrame(CSV.File("$dir1/BAAFFM.csv"));
y = y[217:end-18,:];
Tmonth = size(y)[1];
baaq = zeros(Int(floor(Tmonth / 3)));
for i = 1:Tmonth
    if mod(i, 3) == 0
        j = div(i, 3)
        baaq[j] = mean(y[(j-1)*3+1:3*j, 2]);
    end
end

#= ------------------------------------------------------------------------
 [1.3]Import Price Index:Industrialized Countries- Manufactured articles
 link: https://fred.stlouisfed.org/series/INDUSMANU
 The monthly data starts at `1990M12`
 The quaterly starts at 1994Q1
 ------------------------------------------------------------------------ =#
y = DataFrame(CSV.File("$dir1/INDUSMANU.csv"));
y = y[86:end-18,:];
y = parse.(Float64,convert(Vector,y[:,2]));
Tmonth = size(y)[1];
indusq = zeros(Int(floor(Tmonth / 3)));
for i = 1:Tmonth
    if mod(i, 3) == 0
        j = div(i, 3)
        indusq[j] = mean(y[(j-1)*3+1:3*j])/100
    end
end

#= ------------------------------------------------------------------------
	[1.4] Commodity Prices
		Link: https://www.imf.org/en/Research/commodity-prices
		Commodity Data Portal
 ------------------------------------------------------------------------ =#
y = XLSX.readdata("$dir1/ExternalData.xlsx","Values!A149:CJ490");
y = y[73:end-18, 1:2];
Tmonth = size(y)[1];
commq = zeros(Int(floor(Tmonth / 3)));
for i = 1:Tmonth
    if mod(i, 3) == 0
        j = div(i, 3)
        commq[j] = mean(y[(j-1)*3+1:3*j, 2])
    end
end
commq = commq ./ indusq; # Real price of COMMODITIES
commq = log.(commq);

# ------------------------------------------------------------------------
# Graphics for global variables
# ------------------------------------------------------------------------

Wvar = [g20 commq baaq];
wvar = Wvar[2:end, :] - Wvar[1:end-1, :];
wvar = [100 * wvar[:, 1:2] 0.5 * Wvar[2:end, 3]];
Wlabel = qlabel[2:end];

T = size(wvar)[1];
p = plot(
    wvar[:, [1, 3]],
    ylims = (-2, 5),
    fg_legend = :transparent,
    legendfontsize = 6,
    label = ["G20 output" "BAA spread"],
    legend = :bottomleft,
    xticks = (1:12:T, Wlabel[1:12:T]),
    w = [1 2.5],
    style = [:dash :dot],
    c = [:black :gray],
    title = "Figure 1: Evolution of macro variables",
    titlefontsize = 10,
    ygrid = :none,
)
p = twinx();
plot!(
    p,
    wvar[:, 2],
    ylims = (-45, 40),
    legend = false,
    xticks = :none,
    c = :red,
    w = 1.15,
    alpha = 0.75,
    ygridstyle = :dash,
);
plot!(NaN .* (1:T), c = :red, label = "Real commodity prices");
savefig(".//Figures//intro1.svg");

#= ------------------------------------------------------------------------
 	 [-] COMMODITIES PRICES BY COUNTRY
			Link: https://www.imf.org/en/Research/commodity-prices
			To obtain the price of differents commodities we can choose
				COMMODITY DATA PORTAL
				For Commoditi price index by country we choose
				Commodity terms of trade
				selected: Commodity Export Price Index, Individual Commodites
				Weighted by Ratio of Exports to Total Commodity Exports
				Recent, Monthly (1980 - present), Fixed Weights,
				Index (June 2012 = 100)"
 ------------------------------------------------------------------------ =#

y = XLSX.readdata(
    "$dir1/Commodity_Terms_of_Trade_Commodity_.xlsx",
    "data!A2:AKF184",
)
y= [y[:, 1] y[:, 2:2:end]];
y[1, 1] = "Country";
y= [y[:,1] y[:,218:469]];

list =
    ["Argentina" "Brazil" "Chile" "Colombia" "South Africa" "Peru" "Australia" "Canada" "New Zealand" "Norway"];
index = [findfirst(x -> x == i, y[:, 1]) for i in list];
y = dropdims(y[index, :], dims = 1);
y = y[:, 2:end];

# ------------------------------------------------------------------------
# Quarterly commodities
Tmonth = size(y)[2];
tot   = zeros(10, Int(floor(Tmonth / 3)));
for i = 1:Tmonth
    if mod(i, 3) == 0
        j = div(i, 3)
        tot[:, j] = mean(y[:, (j-1)*3+1:3*j], dims = 2)
    end
end
tot   = tot' ./ indusq;
tot   = log.(tot);
dtot  = tot[5:end,:] - tot[1:end-4,:];
dtot2 = (dtot .- mean(dtot, dims = 1)) ./ std(dtot, dims = 1);
T  = size(dtot)[1];
p1 = plot(layout = grid(3, 1), size = (1000, 1000))
plot!(
    dtot[:, 1:3],
    c = [:black :red :teal],
    markershape = [:none :circle :none],
    w = [1 1.5 1],
    markersize = 2.5,
    markercolor = :red,
    markerstrokewidth = 0.1,
    style = [:solid :dot :solid],
    xaxis = false,
    grid = false,
    label = [list[1] list[2] list[3]],
    legendfontsize = 9,
    legend = :topleft,
    fg_legend = :transparent,
    bg_legend = :transparent,
    subplot = 1,
    tickfontsize = 10,
);
plot!(
    dtot[:, 4:6],
    c = [:black :red :teal],
    markershape = [:none :circle :none],
    w = [1 1.5 1],
    markersize = 2.5,
    markercolor = :red,
    markerstrokewidth = 0.1,
    style = [:solid :dot :solid],
    xaxis = false,
    grid = false,
    label = [list[4] list[5] list[6]],
    legendfontsize = 9,
    legend = :topleft,
    fg_legend = :transparent,
    bg_legend = :transparent,
    subplot = 2,
    tickfontsize = 10,
);
plot!(
    dtot[:, 7:10],
    c = [:black :red :teal :purple],
    markershape = [:none :circle :none :none],
    w = [1 1.5 1 1],
    markersize = 2.5,
    markercolor = :red,
    markerstrokewidth = 0.1,
    style = [:solid :dot :solid :solid],
    xticks = (1:24:T, qlabel[5:24:T+4]),
    grid = false,
    label = [list[7] list[8] list[9] list[10]],
    legendfontsize = 9,
    legend = :topleft,
    fg_legend = :transparent,
    bg_legend = :transparent,
    subplot = 3,
    tickfontsize = 10,
);
plot(p1);
savefig(".//Figures//comm1.svg");

p2 = plot(layout = grid(3, 1), size = (1000, 1000))
plot!(
    dtot2[:, 1:3],
    c = [:black :red :teal],
    markershape = [:none :circle :none],
    w = [1 1.5 1],
    markersize = 2.5,
    markercolor = :red,
    markerstrokewidth = 0.1,
    style = [:solid :dot :solid],
    xaxis = false,
    grid = false,
    label = [list[1] list[2] list[3]],
    legendfontsize = 9,
    legend = :topleft,
    fg_legend = :transparent,
    bg_legend = :transparent,
    subplot = 1,
    tickfontsize = 10,
);
plot!(
    dtot2[:, 4:6],
    c = [:black :red :teal],
    markershape = [:none :circle :none],
    w = [1 1.5 1],
    markersize = 2.5,
    markercolor = :red,
    markerstrokewidth = 0.1,
    style = [:solid :dot :solid],
    xaxis = false,
    grid = false,
    label = [list[4] list[5] list[6]],
    legendfontsize = 9,
    legend = :topleft,
    fg_legend = :transparent,
    bg_legend = :transparent,
    subplot = 2,
    tickfontsize = 10,
);
plot!(
    dtot2[:, 7:10],
    c = [:black :red :teal :purple],
    markershape = [:none :circle :none :none],
    w = [1 1.5 1 1],
    markersize = 2.5,
    markercolor = :red,
    markerstrokewidth = 0.1,
    style = [:solid :dot :solid :solid],
    xticks = (1:24:T, qlabel[5:24:T+4]),
    grid = false,
    label = [list[7] list[8] list[9] list[10]],
    legendfontsize = 9,
    legend = :topleft,
    fg_legend = :transparent,
    bg_legend = :transparent,
    subplot = 3,
    tickfontsize = 10,
);
plot(p2);
savefig(".//Figures//comm2.svg");

#= ------------------------------------------------------------------------
 	 [-] REAL EFFECTIVE EXCHANGE RATE
	 	link:https://www.bis.org/statistics/eer.htm?m=6%7C381%7C676
		narrow indices
		The indices starts at 1994-1
 ------------------------------------------------------------------------ =#
y  = XLSX.readdata(
     "$dir1/broad.xlsx",
     "Real!A4:BI322",
);
y = y[1:302,:];
index = [findfirst(x -> x == i, y[1, :]) for i in list];
y  = dropdims(y[:,index], dims=2);
y  = y[51:end,:];
Tmonth = size(y)[1];
reer  = zeros(Int(floor(Tmonth / 3)),10);
for i = 1:Tmonth
    if mod(i, 3) == 0
        j = div(i, 3)
        reer[j,:] = mean(y[(j-1)*3+1:3*j,:], dims = 1)
    end
end
reer = log.(reer);
#= ------------------------------------------------------------------------
 	[-] NATIONAL ACCOUNTS
	[]  https://data.imf.org/regular.aspx?key=61545852
	[*] https://www.banrep.gov.co/es/catalogo-estadisticas-disponibles#pib1994
	Oferta y Demanda Finales en el Territorio Nacional /
		Precios constantes / Miles de millones de pesos /
		Trimestral / Información disponible desde 2005
	Oferta y demanda finales en el territorio nacional /
		Precios constantes / Miles de millones de pesos /
		Desestacionalizada trimestral / Información disponible desde 2000
	Oferta y demanda finales en el territorio nacional /
		A precios constantes / A millones de pesos /
		Trimestral / Información disponibles desde 1994 a 2007
	[**] Adjusted by seasonality using XArima13 in R

Mostly the structure of the matrices is
 [1] GDP      [2] Consumption  [3] Investment  [4] Exports
 [5] Imports  [6] Real GDP

And we want
GDP         --> [6]
CONSUMPTION --> [2]/[1] * [6]
INVESTMENT  --> [3]/[1] * [6]
TRADE       --> ([4] - [5])/[1]
 -------------------------------------------------------------------------- =#
Dataextract(y) =  begin
	# It puts in real terms everything
	d1 = y[6,:];                   # this is the real GDP
	d2 = (y[2,:] ./ y[1,:]) .* d1; # real consumption
	d3 = (y[3,:] ./ y[1,:]) .* d1; # real investment
	d4 = (y[4,:] .- y[5,:]) ./ y[1,:]; # % net exports
	return  convert(Matrix{Float64},[d1 d2 d3 100*d4]);
end

YBase(y,start) = begin
	# It put the serie y in a year base
	return log.(100* (y ./ mean(y[start:start+3])))
end

#= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	Argentina
	Not seasonal adjusted
	Start: 1993Q1
	Base : 2000
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ =#
basey = 2000;
y    = DataFrame(XLSX.readdata("$dir1/GDP1.xlsx", "Quarterly!B8:DU31"));
aux1 = convert(Vector{Float64},y[12,17:end]);
	# -----------------------
	# Removing the seasonality
	# -----------------------
	@rput aux1
	R" library(seasonal)";
	R" aux2 = ts(aux1, frequency = 4, start = c(1993, 1))";
	#R" plot(aux2)"
	R" m <- seas(aux2)";
	#R" plot(m)";
	R" out1 = m$data";
	@rget out1;
	out1 = out1[:,3]; # This is the series without seasonal effects

y  = convert(Matrix,y[[3,4, 6, 8, 9,12],17:end]);
ec1= Dataextract(y);
seas = y[6,:] ./ out1
ec1  = ec1 ./ seas;

stq = (basey-1993)*4+1;
ec1 = [YBase(ec1[:,1],stq) YBase(ec1[:,2],stq) YBase(ec1[:,3],stq) ec1[:,4]];
ec1 = ec1[21:104,:];
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Brazil
# Start at 1996Q1
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

y  = DataFrame(XLSX.readdata("$dir1/GDP3.xlsx", "Quarterly!B8:DP30"));
y  = convert(Matrix,y[[14,15,17,19,20,22],25:end]);
ec2= Dataextract(y);
stq = (basey-1996)*4+1;
ec2 = [YBase(ec2[:,1],stq) YBase(ec2[:,2],stq) YBase(ec2[:,3],stq) ec2[:,4]];
ec2 = ec2[9:92,:];

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Chile
# Start at 1996Q1
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
y  = DataFrame(XLSX.readdata("$dir1/GDP5.xlsx", "Quarterly!B8:DU30"));
y  = convert(Matrix,y[[14,15,17,19,20,22],29:end]);
ec3= Dataextract(y);
stq= (basey-1996)*4+1;
ec3= [YBase(ec3[:,1],stq) YBase(ec3[:,2],stq) YBase(ec3[:,3],stq) ec3[:,4]];
ec3 = ec3[9:92,:];
#= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Colombia
 * It is already adjusted by
 seasonallity, but I need to chain
 the data to have a sample from 1994
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ =#
y  = DataFrame(XLSX.readdata("$dir1/ColGDP.xlsx", "data!A3:CW8"));
y  = convert(Matrix,y[2:end, 2:end]);
y  = y';
stq= (basey-1994)*4+1;
ec4= [YBase(y[:,1],stq) YBase(y[:,2],stq) YBase(y[:,3],stq) y[:,4]];
ec4= ec4[17:100,:];
#= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Peru
 ** It was adjusted with XArima13
 Starts at 1998Q1 all variable are real but not seassonaly adjusted
 https://estadisticas.bcrp.gob.pe/estadisticas/series/trimestrales/pbi-gasto
 Series:
	PN02529AQ 	Demanda Interna - Consumo Privado
	PN02533AQ  	Demanda Interna - Inversión Bruta Interna -
				Inversión Bruta Fija - Privada
	PN02536AQ	Exportaciones
	PN02537AQ	Importaciones
	PN02538AQ	PBI
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ =#
y  = DataFrame(XLSX.readdata("$dir1/Trimestral.xlsx", "Trimestrales!A2:F86"));

 # -----------------------
 # Removing the seasonality
 # -----------------------
	aux1 = convert(Vector{Float64},y[2:end,6]);
	@rput aux1
	R" library(seasonal)";
	R" aux2 = ts(aux1, frequency = 4, start = c(1998, 1))";
	#R" plot(aux2)"
	R" m <- seas(aux2)";
	#R" plot(m)";
	R" out1 = m$data";
	@rget out1;
	out1 = out1[:,3]; # This is the series without seasonal effects
	seas = aux1./out1
y  = convert(Matrix{Float64},y[2:end,2:end] ./ (seas));
trade = 100*((y[:,3] - y[:,4])./ y[:,5])
stq= (basey-1998)*4+1;
ec5= [YBase(y[:,5],stq) YBase(y[:,1],stq) YBase(y[:,2],stq) trade];

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# South Africa
# Starts at 1990Q1
# Additionally: http://www.statssa.gov.za/?page_id=1854&PPN=P0441&SCH=7746
#		GDP P0441- 2020Q1 (7,83 MB)
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
y  = DataFrame(XLSX.readdata("$dir1/GDP10.xlsx", "Quarterly!B8:DQ31"));
y  = convert(Matrix,y[[15,16,18,20,21,24],5:end]);
ec6= Dataextract(y);
stq= (basey-1990)*4+1;
ec6= [YBase(ec6[:,1],stq) YBase(ec6[:,2],stq) YBase(ec6[:,3],stq) ec6[:,4]];
ec6 = ec6[33:116,:]

# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Australia
# Starts at 1990Q1
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
y  = DataFrame(XLSX.readdata("$dir1/GDP2.xlsx", "Quarterly!B8:DU32"));
y  = convert(Matrix,y[[15,16,18,20,21,24],5:end]);
dc1= Dataextract(y);
stq= (basey-1990)*4+1;
dc1= [YBase(dc1[:,1],stq) YBase(dc1[:,2],stq) YBase(dc1[:,3],stq) dc1[:,4]];
dc1 = dc1[33:116,:];
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Canada
# Starts at 1990Q1
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
y  = DataFrame(XLSX.readdata("$dir1/GDP4.xlsx", "Quarterly!B8:DS29"));
y  = convert(Matrix,y[[12,13,15, 17, 18, 21],5:end]);
dc2= Dataextract(y);
stq= (basey-1990)*4+1;
dc2= [YBase(dc2[:,1],stq) YBase(dc2[:,2],stq) YBase(dc2[:,3],stq) dc2[:,4]];
dc2 = dc2[33:116,:];
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# New Zealand
# Starts at 1990Q1
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
y  = DataFrame(XLSX.readdata("$dir1/GDP7.xlsx", "Quarterly!B8:DU32"));
y  = convert(Matrix,y[[15,16, 18,20,21,24],5:end]);
dc3= Dataextract(y);
stq= (basey-1990)*4+1;
dc3= [YBase(dc3[:,1],stq) YBase(dc3[:,2],stq) YBase(dc3[:,3],stq) dc3[:,4]];
dc3 = dc3[33:116,:];
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Norway
# Starts at 1990Q1
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
y  = DataFrame(XLSX.readdata("$dir1/GDP8.xlsx", "Quarterly!B8:DV30"));
y  = convert(Matrix,y[[14,15,17,19,20,22],5:end]);
dc4= Dataextract(y);
stq= (basey-1990)*4+1;
dc4= [YBase(dc4[:,1],stq) YBase(dc4[:,2],stq) YBase(dc4[:,3],stq) dc4[:,4]];
dc4 = dc4[33:116,:];

#= ------------------------------------------------------------------------
 	[-] INTEREST RATES
https://www.bis.org/statistics/cbpol.htm?m=6%7C382%7C679
https://estadisticas.bcrp.gob.pe/estadisticas/series/mensuales/tasas-de-interes
 -------------------------------------------------------------------------- =#
irate = XLSX.readdata("$dir1/cbpol_2007.xlsx", "Monthly!A3:K321");
y2    = XLSX.readdata("$dir1/intratePer.xlsx", "Mensuales!A2:B296");
yy = [irate[26:end,10] y2[2:end,2]];
dplot = convert(Matrix{Float64},yy[94:end,:]);
plot(dplot)
# Then the overnight interbak lending rate is a good proxy of mp
irate[26:end,10] = y2[2:end,2];
# Now, putting in the correct order
index = [findfirst(x -> x == i, irate[1,:]) for i in list];
irate = dropdims(irate[50:end-18,index], dims=2);
Tmonth = size(irate)[1];
irateq = zeros(Int(floor(Tmonth / 3)),10);
for i = 1:Tmonth
    if mod(i, 3) == 0
        j = div(i, 3)
        irateq[j,:] = mean(irate[(j-1)*3+1:3*j,:], dims = 1)
    end
end

Δipc = XLSX.readdata("$dir1/inflation.xlsx", "data!A1:K301");
index = [findfirst(x -> x == i, Δipc[1,:]) for i in list];
Δipc = dropdims(Δipc[2:end,index], dims=2);
Tmonth = size(Δipc)[1];
Δipcq = zeros(Int(floor(Tmonth / 3)),10);
for i = 1:Tmonth
    if mod(i, 3) == 0
        j = div(i, 3)
        Δipcq[j,:] = Δipc[i,:]
    end
end
Δipcq = Δipcq[17:end,:]
rrateq = irateq - Δipcq
#= ------------------------------------------------------------------------
	CREATING THE DATASET
The order of the variables are:
g20 >> comm >> baa >> gdp >> cons >> inv >> trade >> reer >> irate
-------------------------------------------------------------------------- =#
mec1 = convert(Array{Float64},[g20 tot[:,1] baaq ec1 reer[:,1] rrateq[:,1]]);
mec2 = convert(Array{Float64},[g20 tot[:,2] baaq ec2 reer[:,2] rrateq[:,2]]);
mec3 = convert(Array{Float64},[g20 tot[:,3] baaq ec3 reer[:,3] rrateq[:,3]]);
mec4 = convert(Array{Float64},[g20 tot[:,4] baaq ec4 reer[:,4] rrateq[:,4]]);
mec5 = convert(Array{Float64},[g20 tot[:,5] baaq ec5 reer[:,5] rrateq[:,5]]);
mec6 = convert(Array{Float64},[g20 tot[:,6] baaq ec6 reer[:,6] rrateq[:,6]]);
mec7 = convert(Array{Float64},[g20 tot[:,7] baaq dc1 reer[:,7] rrateq[:,7]]);
mec8 = convert(Array{Float64},[g20 tot[:,8] baaq dc2 reer[:,8] rrateq[:,8]]);
mec9 = convert(Array{Float64},[g20 tot[:,9] baaq dc3 reer[:,9] rrateq[:,9]]);
mec10 = convert(Array{Float64},[g20 tot[:,10] baaq dc4 reer[:,10] rrateq[:,10]]);
dataset = (mec1, mec2, mec3, mec4, mec5, mec6, mec7, mec8, mec9, mec10)
return wvar,dataset, qlabel,list;
end

max_stars_repo_name: ChrisVeJa/GlobalShock

max_issues_repo_name: ChrisVeJa/GlobalShock

max_forks_repo_name: ChrisVeJa/GlobalShock


text:
# Autogenerated wrapper script for LibCURL_jll for x86_64-unknown-freebsd
export curl, libcurl

using LibSSH2_jll
using Zlib_jll
using nghttp2_jll
using MbedTLS_jll
JLLWrappers.@generate_wrapper_header("LibCURL")
JLLWrappers.@declare_executable_product(curl)
JLLWrappers.@declare_library_product(libcurl, "libcurl.so.4")
function __init__()
    JLLWrappers.@generate_init_header(LibSSH2_jll, Zlib_jll, nghttp2_jll, MbedTLS_jll)
    JLLWrappers.@init_executable_product(
        curl,
        "bin/curl",
    )

    JLLWrappers.@init_library_product(
        libcurl,
        "lib/libcurl.so",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@generate_init_footer()
end  # __init__()


text:
# Example for HINT scienario 2 (Kruse et al, 2020)
# Obtaining samples from posterior for the following problem:
# y = Ax + ϵ, x ~ N(μ_x, Σ_x), ϵ ~ N(μ_ϵ, Σ_ϵ), A ~ N(0, I/|x|)

using InvertibleNetworks, LinearAlgebra, Test
using Distributions
import Flux.Optimise.update!, Flux
using PyPlot
using Printf
using Random
Random.seed!(19)

# Model and data dimension
dim_model = 8
dim_data = 6

# Prior distribution
μ_x = 3.14f0*ones(Float32, dim_model)
σ_x = 3.0f0
Σ_x = σ_x^2*I
Λ_x = inv(Σ_x)

π_x = MvNormal(μ_x, Σ_x)
x = rand(π_x)

# Distribution of noise
μ_ϵ = 0.0f0*ones(Float32, dim_data)
σ_ϵ = sqrt(0.1f0)
Σ_ϵ = σ_ϵ^2*I
Λ_ϵ = inv(Σ_ϵ)

π_ϵ = MvNormal(μ_ϵ, Σ_ϵ)
ϵ = rand(π_ϵ)

# Forward operator
A = randn(Float32, dim_data, dim_model)/sqrt(dim_model*1.0f0)

# Observation
y = A*x + ϵ

# Analytic posterior distribution
Σ_post = inv(Λ_x + A'*Λ_ϵ*A)
μ_post = Σ_post*A'*Λ_ϵ*(y - μ_ϵ) + Λ_x*μ_x

# Analytic posterior distribution sampler
R = cholesky(Σ_post, check=false).L
standard_normal = MvNormal(zeros(Float32, dim_model), 1.0f0*I)

function post_dist_sample()
	return R*rand(standard_normal) + μ_post
end

# Invertible neural net
nx = 1
ny = 1
n_in = dim_model
n_hidden = 16
batchsize = 8
depth = 4
AN = Array{ActNorm}(undef, depth)
L = Array{CouplingLayerHINT}(undef, depth)
Params = Array{Parameter}(undef, 0)

# Create layers
for j=1:depth
    AN[j] = ActNorm(n_in; logdet=true)
    L[j] = CouplingLayerHINT(n_in, n_hidden; logdet=true,
    						 permute="both", k1=1, k2=1, p1=0, p2=0)

    # Collect parameters
    global Params = cat(Params, get_params(AN[j]); dims=1)
    global Params = cat(Params, get_params(L[j]); dims=1)
end

# Forward pass
function forward(X)
    logdet = 0f0
    for j=1:depth
        X_, logdet1 = AN[j].forward(X)
        X, logdet2 = L[j].forward(X_)
        logdet += (logdet1 + logdet2)
    end
    return X, logdet
end

# Backward pass
function backward(ΔX, X)
    for j=depth:-1:1
        ΔX_, X_ = L[j].backward(ΔX, X)
        ΔX, X = AN[j].backward(ΔX_, X_)
    end
    return ΔX, X
end

# Optimizer
η = 0.01
opt = Flux.ADAM(η)
lr_step = 2000
lr_decay_fn = Flux.ExpDecay(η, .3, lr_step, 0.)

# Loss function
function loss(z_in, y_in)
	x̂, logdet = forward(z_in)

	f = (1f0/2)*(sum((A*x̂[1, 1, :, :] .- y_in)'*Λ_ϵ*(A*x̂[1, 1, :, :] .- y_in)) +
		sum((x̂[1, 1, :, :] .- μ_x)'*Λ_x*(x̂[1, 1, :, :] .- μ_x)))/batchsize - logdet

	ΔY = (A'*Λ_ϵ*(A*x̂[1, 1, :, :] .- y_in) + Λ_x*(x̂[1, 1, :, :] .- μ_x))/batchsize
	ΔX = backward(permutedims(repeat(ΔY, 1, 1, 1, 1), [3, 4, 1, 2]), x̂)[1]
	return f, ΔX
end

# Implementation of scenario 2 at HINT paper
N = 5000
z = randn(Float32, 1, 1, dim_model, N)
max_itr = 5000
fval = zeros(Float32, max_itr)

@printf " [*] Beginning training loop\n"
for j = 1:max_itr

	# Evaluate objective and gradients
	idx = sample(1:N, batchsize; replace=false)
	fval[j] = loss(z[:, :, :, idx], y)[1]
	mod(j, 10) == 0 && (print("Iteration: ", j, "; f = ", fval[j], "\n"))

	# Update params
	for p in Params
		update!(opt, p.data, p.grad)
        update!(lr_decay_fn, p.data, p.grad)
	end
	clear_grad!(Params)

end

# Validation

x̂ = forward(z)[1][1, 1, :, :]

μ_est = mean(x̂; dims=2)
Σ_est = cov(x̂; dims=2, corrected=true)

# Training loss
fig = plt.figure("training logs - net", dpi=150, figsize=(7, 2.5))
plt.plot(fval); plt.title("training loss")
plt.grid()

# Comparing estimated and true mean
fig = plt.figure("Posterior mean", dpi=150, figsize=(12, 2.5))
plt.plot(μ_est, label="Estimated posterior mean")
plt.plot(μ_post, label="True posterior mean")
plt.legend(loc="upper right")
plt.grid()

# Comparing estimated and true covariance matrix
fig = plt.figure("Posterior covariance", dpi=150, figsize=(8, 4));
plt.subplot(121); plt.imshow(Σ_post, vmin=-maximum(Σ_post), vmax=maximum(Σ_post),
	cmap="RdBu")
plt.title("True posterior covariance")
plt.colorbar(fraction=0.0475, pad=0.03)
plt.subplot(122); plt.imshow(Σ_est, vmin=-maximum(Σ_post), vmax=maximum(Σ_post),
	cmap="RdBu")
plt.title("Estimated posterior covariance")
plt.colorbar(fraction=0.0475, pad=0.03)

# Sammpling from true posterior
true_samples = zeros(Float32, dim_model, 100)
for j = 1:100
	true_samples[:, j] = post_dist_sample()
end

# Samples from estimated and true posterior
fig = plt.figure("samples from posterior", dpi=150, figsize=(7, 6))
plt.subplot(211);
for j = 1:100
	plt.plot(true_samples[:, j], linewidth=0.8, alpha=0.5, color="#22c1d6")
plt.grid()
end
plt.title("Samples from true posterior")
plt.subplot(212);
for j =1:100
	plt.plot(x̂[:, j], linewidth=0.8, alpha=0.5, color="k")
plt.grid()
plt.title("Samples from estimated posterior")
end


text:
let sys = DenseSystem(test_params...),
    beta = 12.34,
    basis_size = 10,
    sos = SumOverStates(sys, beta, basis_size)

    @test isapprox(sos.Z, 7.74822371e-3)
    @test isapprox(sos.E, 3.93864802e-1)
    @test isapprox(sos.Cv, 1.04927608e-10)
end


text:
using CompScienceMeshes
using Test

filename = joinpath(dirname(@__FILE__),"from_hollow_waveguide.tri.txt")
Γ = CompScienceMeshes.read_TRI_mesh(filename)

@test numvertices(Γ) == 396
@test numcells(Γ) == 300


text:
module EVQueues

using ProgressMeter, Distributions, Serialization, JuMP, GLPK, DataFrames, DataStructures

export  compute_statistics!, get_vehicle_trajectories, compute_fairness, generate_Poisson_stream, ev_sim_trace,
        EVSim, loadsim, savesim

include("types.jl") ##Type definitions
include("utilities.jl") ##codigo con utilidades varias
include("ev_sim.jl")  ##codigo del simulador comun
include("ev_sim_trace.jl") ##codigo del simulador a partir de trazas
include("ev_sim_uncertain.jl") ##codigo del simulador con incertidumbre en el deadline
include("policies.jl")  ##codigo que implementa las politicas
include("plot_recipes.jl") ##plots

end #end module


text:
module test_evalpoly
using Yeppp

const c0 =    1.53270461724076346
const c1 =    1.45339856462100293
const c2 =    1.21078763026010761
const c3 =    1.46952786401453397
const c4 =    1.34249847863665017
const c5 =    0.75093174077762164
const c6 =    1.90239336671587562
const c7 =    1.62162053962810579
const c8 =    0.53312230473555923
const c9 =    1.76588453111778762
const c10 =   1.31215699612484679
const c11 =   1.49636144227257237
const c12 =   1.52170011054112963
const c13 =   0.83637497322280110
const c14 =   1.12764540941736043
const c15 =   0.65513628703807597
const c16 =   1.15879020877781906
const c17 =   1.98262901973751791
const c18 =   1.09134643523639479
const c19 =   1.92898634047221235
const c20 =   1.01233347751449659
const c21 =   1.89462732589369078
const c22 =   1.28216239080886344
const c23 =   1.78448898277094016
const c24 =   1.22382217182612910
const c25 =   1.23434674193555734
const c26 =   1.13914782832335501
const c27 =   0.73506235075797319
const c28 =   0.55461432517332724
const c29 =   1.51704871121967963
const c30 =   1.22430234239661516
const c31 =   1.55001237689160722
const c32 =   0.84197209952298114
const c33 =   1.59396169927319749
const c34 =   0.97067044414760438
const c35 =   0.99001960195021281
const c36 =   1.17887814292622884
const c37 =   0.58955609453835851
const c38 =   0.58145654861350322
const c39 =   1.32447212043555583
const c40 =   1.24673632882394241
const c41 =   1.24571828921765111
const c42 =   1.21901343493503215
const c43 =   1.89453941213996638
const c44 =   1.85561626872427416
const c45 =   1.13302165522004133
const c46 =   1.79145993815510725
const c47 =   1.59227069037095317
const c48 =   1.89104468672467114
const c49 =   1.78733894997070918
const c50 =   1.32648559107345081
const c51 =   1.68531055586072865
const c52 =   1.08980909640581993
const c53 =   1.34308207822154847
const c54 =   1.81689492849547059
const c55 =   1.38582137073988747
const c56 =   1.04974901183570510
const c57 =   1.14348742300966456
const c58 =   1.87597730040483323
const c59 =   0.62131555899466420
const c60 =   0.64710935668225787
const c61 =   1.49846610600978751
const c62 =   1.07834176789680957
const c63 =   1.69130785175832059
const c64 =   1.64547687732258793
const c65 =   1.02441150427208083
const c66 =   1.86129006037146541
const c67 =   0.98309038830424073
const c68 =   1.75444578237500969
const c69 =   1.08698336765112349
const c70 =   1.89455010772036759
const c71 =   0.65812118412299539
const c72 =   0.62102711487851459
const c73 =   1.69991208083436747
const c74 =   1.65467704495635767
const c75 =   1.69599459626992174
const c76 =   0.82365682103308750
const c77 =   1.71353437063595036
const c78 =   0.54992984722831769
const c79 =   0.54717367088443119
const c80 =   0.79915543248858154
const c81 =   1.70160318364006257
const c82 =   1.34441280175456970
const c83 =   0.79789486341474966
const c84 =   0.61517383020710754
const c85 =   0.55177400048576055
const c86 =   1.43229889543908696
const c87 =   1.60658663666266949
const c88 =   1.78861146369896090
const c89 =   1.05843250742401821
const c90 =   1.58481799048208832
const c91 =   1.70954313374718085
const c92 =   0.52590070195022226
const c93 =   0.92705074709607885
const c94 =   0.71442651832362455
const c95 =   1.14752795948077643
const c96 =   0.89860175106926404
const c97 =   0.76771198245570573
const c98 =   0.67059202034800746
const c99 =   0.53785922275590729
const c100 =  0.82098327929734880

const coeff = [c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10,
               c11, c12, c13, c14, c15, c16, c17, c18, c19, c20,
               c21, c22, c23, c24, c25, c26, c27, c28, c29, c30,
               c31, c32, c33, c34, c35, c36, c37, c38, c39, c40,
               c41, c42, c43, c44, c45, c46, c47, c48, c49, c50,
               c51, c52, c53, c54, c55, c56, c57, c58, c59, c60,
               c61, c62, c63, c64, c65, c66, c67, c68, c69, c70,
               c71, c72, c73, c74, c75, c76, c77, c78, c79, c80,
               c81, c82, c83, c84, c85, c86, c87, c88, c89, c90,
               c91, c92, c93, c94, c95, c96, c97, c98, c99, c100]

function horner!(xv::Vector{Float64}, y::Vector{Float64})
    for i in 1:length(xv)
        x = xv[i]
        y[i] =  c0 + x * (c1 + x * (c2 + x * (c3 + x * (c4 + x * (c5 + x * (c6 + x * (c7 + x * (c8 + x * (c9 + x * (c10 + x * (c11 +
                              x * (c12 + x * (c13 + x * (c14 + x * (c15 + x * (c16 + x * (c17 + x * (c18 + x * (c19 + x * (c20 + x * (c21 +
                              x * (c22 + x * (c23 + x * (c24 + x * (c25 + x * (c26 + x * (c27 + x * (c28 + x * (c29 + x * (c30 + x * (c31 +
                              x * (c32 + x * (c33 + x * (c34 + x * (c35 + x * (c36 + x * (c37 + x * (c38 + x * (c39 + x * (c40 + x * (c41 +
                              x * (c42 + x * (c43 + x * (c44 + x * (c45 + x * (c46 + x * (c47 + x * (c48 + x * (c49 + x * (c50 + x * (c51 +
                              x * (c52 + x * (c53 + x * (c54 + x * (c55 + x * (c56 + x * (c57 + x * (c58 + x * (c59 + x * (c60 + x * (c61 +
                              x * (c62 + x * (c63 + x * (c64 + x * (c65 + x * (c66 + x * (c67 + x * (c68 + x * (c69 + x * (c70 + x * (c71 +
                              x * (c72 + x * (c73 + x * (c74 + x * (c75 + x * (c76 + x * (c77 + x * (c78 + x * (c79 + x * (c80 + x * (c81 +
                              x * (c82 + x * (c83 + x * (c84 + x * (c85 + x * (c86 + x * (c87 + x * (c88 + x * (c89 + x * (c90 + x * (c91 +
                              x * (c92 + x * (c93 + x * (c94 + x * (c95 + x * (c96 + x * (c97 + x * (c98 + x * (c99 + x * c100)
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
    end
end

function horner_gen!(coef::Vector{Float64}, x::Vector{Float64}, y::Vector{Float64})
  n = length(x)
  ncoef = length(coef)
  for i in 1:n
    xc = x[i]
    sum = coef[ncoef]
    for k in (ncoef - 1):-1:1
      sum = coef[k] + xc * sum
    end
    y[i] = sum
  end
end

function runtest(n::Int = 10^7)
    x = collect(linspace(0,1,n))
    y1 = zeros(n)
    y2 = zeros(n)
    y3 = zeros(n)

    tyeppp = @elapsed Yeppp.evalpoly!(y1, coeff, x)
    thorner = @elapsed horner!(x, y2)
    thorner2 = @elapsed horner_gen!(coeff, x, y3)

    @printf "Evalpoly test, size %d\n" n
    @printf "Yeppp time: %f. Error relative to horner_gen!: %e.\n" tyeppp sqrt(sumabs2(y3-y1))
    @printf "Explicit Horner method: %f. Error relative to horner_gen!: %e\n" thorner sqrt(sumabs2(y3-y1))
    @printf "General Horner method: %f\n" thorner2

end
runtest()

end