text:
using JuMP, EAGO

                     m = Model()

                     EAGO.register_eago_operators!(m)

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

                     @variable(m, -12.548880784274985 <= q <= 15.06837792907793)

                     add_NL_constraint(m, :((0.4386422028907555 + 0.03049853723546203*(-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + -0.7963936693468932*(0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + -0.19871150900740808*(-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((0.4386422028907555 + 0.03049853723546203*(-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + -0.7963936693468932*(0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + -0.19871150900740808*(-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2 + (0.039843038969352484 + 0.2885956651060697*(-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.8477392827604406*(0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + -0.38122333260621444*(-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((0.039843038969352484 + 0.2885956651060697*(-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.8477392827604406*(0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + -0.38122333260621444*(-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2 + (0.5234531332153054 + -0.26529753551452195*(-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.29155449146294243*(0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + -0.357141816330512*(-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2)*(1 + erf((0.5234531332153054 + -0.26529753551452195*(-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.33806544253006265 + -0.5419050015026476*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.12420368558845318*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.008939690927983968*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + 0.29155449146294243*(0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((0.35455126051631725 + -0.3141650319667155*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + 0.26311214619974344*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + -0.4178451532515153*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2 + -0.357141816330512*(-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)*(1 + erf((-0.9712553762218641 + -0.9788234903921222*(0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))*(1 + erf((0.3281182697751017 + -0.8099128015858463*$(x[1]) + 0.13317347784439315*$(x[2]) + 0.4405761556905756*$(x[3]) + 0.9454727306320025*$(x[4]))/sqrt(2)))/2 + -0.6598676192535482*(-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))*(1 + erf((-0.11273025364322331 + 0.7707180324977863*$(x[1]) + -0.4030548048256195*$(x[2]) + 0.6515536701116291*$(x[3]) + -0.7265975512301988*$(x[4]))/sqrt(2)))/2 + 0.7900118209668339*(-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))*(1 + erf((-0.1658555453462811 + -0.8928983125267513*$(x[1]) + 0.8779481001349092*$(x[2]) + -0.7642847980322278*$(x[3]) + -0.7283572839362114*$(x[4]))/sqrt(2)))/2)/sqrt(2)))/2)/sqrt(2)))/2 - $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:
##################################################################################
# This file is part of StateSpaceEcon.jl
# BSD 3-Clause License
# Copyright (c) 2020-2022, Bank of Canada
# All rights reserved.
##################################################################################

"""
    SimData

Data structure containing the time series data for a simulation.

It is a collection of [`TSeries`](@ref) of the same frequency and containing
data for the same range. When used for simulation, the range must include the
initial conditions, the simulation range and the final conditions, although it
could extend beyond that. It must contain time series for all variables and
shocks in the model, although it might contain other time series.

"""
const SimData = MVTSeries{F,Float64} where {F<:Frequency}
export SimData

# same constructors as should work for SimData
SimData(args...) = MVTSeries(args...)

const _MVCollection = Union{Vector{ModelVariable},NTuple{N,ModelVariable}} where {N}
# we should allow indexing with model variables
Base.getindex(sd::SimData, vars::_MVCollection) = getindex(sd, map(v -> v.name, vars))
Base.getindex(sd::SimData, vars::ModelVariable) = getindex(sd, vars.name)
Base.setindex!(sd::SimData, val, vars::_MVCollection) = setindex!(sd, val, map(v -> v.name, vars))
Base.setindex!(sd::SimData, val, vars::ModelVariable) = setindex!(sd, val, vars.name)

Base.getindex(sd::SimData, rows, vars::_MVCollection) = getindex(sd, rows, map(v->v.name, vars))
Base.getindex(sd::SimData, rows, vars::ModelVariable) = getindex(sd, rows, vars.name)
Base.setindex!(sd::SimData, val, rows, vars::_MVCollection) = setindex!(sd, val, rows, map(v->v.name, vars))
Base.setindex!(sd::SimData, val, rows, vars::ModelVariable) = setindex!(sd, val, rows, vars.name)

Base.view(sd::SimData, rows, vars::_MVCollection) = view(sd, rows, map(v->v.name, vars))
Base.view(sd::SimData, rows, vars::ModelVariable) = view(sd, rows, vars.name)

ext: jl


text:
"""
    OperatorIndexTable(roots::Set{Int}, operators::Dict{LogicalOperation, Vector{OperatorIndexTable}})

Structure for a operator table, which keeps a mapping from operators to their constituent argument subexpressions. Roots is a set
of identifiers which have been matched at this table level and operators is a dictionary mapping each logical operation to a list
of subtables corresponding directly to each of the operator's arguments.

Usually indexes aren't constructed directly through this constructor, but rather through helper functions like [`index`](@ref).
"""
mutable struct OperatorIndexTable <: AbstractDeductiveIndexTable
    roots::Set{Int}
    operators::Dict{LogicalOperation, Vector{OperatorIndexTable}}
end
OperatorMap = Dict{LogicalOperation, Vector{OperatorIndexTable}}
"""
    OperatorIndexTable()

Initializes an empty [`OperatorIndexTable`](@ref).
"""
OperatorIndexTable() = OperatorIndexTable(Set{Int}(), OperatorMap())
"""
    roots(t::OperatorIndexTable)

Gets the `roots` property from an [`OperatorIndexTable`](@ref).
"""
roots(t::OperatorIndexTable) = t.roots
"""
    operators(t::OperatorIndexTable)

Gets the `operators` property from an [`OperatorIndexTable`](@ref).
"""
operators(t::OperatorIndexTable) = t.operators

"""
    add!(table::OperatorIndexTable, entry::Tuple{Int, LogicalSymbol})

Add an index entry to an [`OperatorIndexTable`](@ref) for a [`LogicalSymbol`](@ref). LogicalSymbols are trivial additions
to a operator index since a symbol means that a search has hit a root. Therefore this method just adds the symbol to
the table's roots.
"""
function add!(table::OperatorIndexTable, entry::Tuple{Int, LogicalSymbol})
    expr_id, sym = entry
    push!(roots(table), expr_id)
end
"""
    add!(table::OperatorIndexTable, entry::Tuple{Int, LogicalExpression})

Add an index entry to an [`OperatorIndexTable`](@ref) for a [`LogicalExpression`](@ref). LogicalExpressions get added to
an operator table's roots regardless and each of its arguments get added to its operations corresponding subtables.
"""
function add!(table::OperatorIndexTable, entry::Tuple{Int, LogicalExpression})
    expr_id, expr = entry
    expr_op, expr_args = operation(expr), arguments(expr)

    push!(roots(table), expr_id)

    if !haskey(operators(table), expr_op)
        operators(table)[expr_op] = [OperatorIndexTable() for _ ∈ 1:argument_count(expr_op)]
    end

    op_subtables = operators(table)[expr_op]
    for i ∈ 1:length(op_subtables)
        add!(op_subtables[i], (expr_id, expr_args[i]))
    end
end

"""
    search(table::OperatorIndexTable, sym::LogicalSymbol)

Perform a trivial search in an operator table for a symbol. Since logical symbols are expression tree roots,
this search will immediately return the roots of the particular `OperatorIndexTable`.
"""
search(table::OperatorIndexTable, ::LogicalSymbol) = roots(table)
"""
    search(table::OperatorIndexTable, operator_pattern::LogicalExpression)

Search for an operator pattern in a [`OperatorIndexTable`](@ref).

!!! note
    There's an important distinction between "expression pattern" and "operator pattern". An expression pattern matches both
    operator and symbol structure, while an operator pattern only matches an operator structure. Take the expression
    `(a ∧ b) ∧ c` for instance. The pattern `a ∧ a`, when interpreted as an expression pattern, would _not_ match, while
    when interpreted as an operator pattern it _would_ match.

"""
function search(table::OperatorIndexTable, operator_pattern::LogicalExpression)
    expr_op, expr_args = operation(operator_pattern), arguments(operator_pattern)
    if !haskey(operators(table), expr_op)
        return Set{Int}()
    end
    op_subtables = operators(table)[expr_op]
    return reduce(∩, [search(op_subtables[i], expr_args[i]) for i ∈ 1:length(op_subtables)])
end

"""
    index(expressions::Set{AbstractExpression})

Creates an [`Index`](@ref) for a given set of expressions.
"""
function index(expressions::Set{AbstractExpression})
    root_table = OperatorIndexTable()
    idx = Index(root_table, Dict{Int, AbstractExpression}())

    for expression ∈ expressions
        add!(idx, expression)
    end

    idx
end
"""
    index(expressions::Set{AbstractExpression})

Creates an [`Index`](@ref) for a given vector of expressions. This is the same as indexing the set containing all elements in the vector.
"""
index(expressions::Vector{AbstractExpression}) = index(Set{AbstractExpression}(expressions))


text:
# Test problem functions

# The purpose of the tests contained in this file is to detect if anything has accidentally
# changed in the problem functions. Accordingly, only the termination status and the
# objective value are tested.
# To test specific features, it is better to write ad-hoc tests in other files.

@testset "Problem" begin

    t_data = create_multi_year_network_data("case6", 4, 2, 3; cost_scale_factor=1e-6)
    t_data_1scenario = _FP.slice_multinetwork(t_data; scenario=1)
    setting = Dict("conv_losses_mp" => false)

    d_data = load_cigre_mv_eu(; # TODO: use a test case with multiple years and scenarios when available.
        flex_load = true,
        ne_storage = true,
        scale_load = 6.0,
        number_of_hours = 4,
        cost_scale_factor = 1e-6
    )

    @testset "TNEP without flex loads" begin
        @testset "Transmission" begin
            result = _FP.strg_tnep(t_data_1scenario, _PM.DCPPowerModel, cbc; setting)
            @test result["termination_status"] == _PM.OPTIMAL
            @test result["objective"] ≈ 7489.8 rtol=1e-3
        end
        @testset "Distribution" begin
            result = _FP.strg_tnep(d_data, _FP.BFARadPowerModel, cbc)
            @test result["termination_status"] == _PM.OPTIMAL
            @test result["objective"] ≈ 355.0 rtol=1e-3
        end
    end

    @testset "TNEP" begin
        @testset "Transmission" begin
            result = _FP.flex_tnep(t_data_1scenario, _PM.DCPPowerModel, cbc; setting)
            @test result["termination_status"] == _PM.OPTIMAL
            @test result["objective"] ≈ 7486.2 rtol=1e-3
        end
        @testset "Distribution" begin
            result = _FP.flex_tnep(d_data, _FP.BFARadPowerModel, cbc)
            @test result["termination_status"] == _PM.OPTIMAL
            @test result["objective"] ≈ 354.6 rtol=1e-3
        end
    end

    @testset "Stochastic TNEP" begin
        @testset "Transmission" begin
            result = _FP.stoch_flex_tnep(t_data, _PM.DCPPowerModel, cbc; setting)
            @test result["termination_status"] == _PM.OPTIMAL
            @test result["objective"] ≈ 7702.3 rtol=1e-3
        end
        @testset "Distribution" begin
            result = _FP.stoch_flex_tnep(d_data, _FP.BFARadPowerModel, cbc)
            @test result["termination_status"] == _PM.OPTIMAL
            @test result["objective"] ≈ 354.6 rtol=1e-3
        end
    end

    @testset "Simplified stochastic TNEP" begin
        @testset "Transmission" begin
            result = _FP.simple_stoch_flex_tnep(t_data, _PM.DCPPowerModel, cbc; setting)
            @test result["termination_status"] == _PM.OPTIMAL
            @test result["objective"] ≈ 7617.5 rtol=1e-3
        end
        @testset "Distribution" begin
            result = _FP.simple_stoch_flex_tnep(d_data, _FP.BFARadPowerModel, cbc)
            @test result["termination_status"] == _PM.OPTIMAL
            @test result["objective"] ≈ 354.6 rtol=1e-3
        end
    end

end;


text:
# network structure rework: split into 3 different structures: network, batch_trainer and batch_tester for preallocation
# the whole run time is faster due to preallocation for evaluation batch (batch_tester)
using LinearAlgebra
using MLDatasets
using Random

@inline σ(z) = 1/(1+exp(-z))
@inline σ_grad(z) = σ(z)*(1-σ(z))

struct network_v4
    num_layers::Int64
    sizearr::Array{Int64,1}
    biases::Array{Array{Float64,1},1}
    weights::Array{Array{Float64,2},1}
end
function network_v4(sizes)
    num_layers = length(sizes)
    sizearr = sizes
    biases = [randn(y) for y in sizes[2:end]]
    weights = [randn(y, x) for (x, y) in zip(sizes[1:end-1], sizes[2:end])]
    network_v4(num_layers, sizearr, biases, weights)
end
function (net::network_v4)(a)
    for (w, b) in zip(net.weights, net.biases)
        a = σ.(w*a .+ b)
    end
    return a
end

struct batch_trainer
    η::Float64
    batch_size::Int64
    ∇_b::Array{Array{Float64,1},1}
    ∇_w::Array{Array{Float64,2},1}
    zs::Array{Array{Float64,2},1}
    activations::Array{Array{Float64,2},1}
    δs::Array{Array{Float64,2},1}
end
function batch_trainer(net::network_v4, batch_size, η)
    sizes = net.sizearr
    ∇_b = [zeros(y) for y in sizes[2:end]]
    ∇_w = [zeros(y, x) for (x, y) in zip(sizes[1:end-1], sizes[2:end])]
    zs = [zeros(y, batch_size) for y in sizes[2:end]]
    activations = [zeros(y, batch_size) for y in sizes[2:end]]
    δs = [zeros(y, batch_size) for y in sizes[2:end]]
    batch_trainer(η, batch_size, ∇_b, ∇_w, zs, activations, δs)
end

struct batch_tester
    batch_size::Int64
    zs::Array{Array{Float64,2},1}
    activations::Array{Array{Float64,2},1}
    δs::Array{Array{Float64,2},1}
end
function batch_tester(net::network_v4, batch_size)
    sizes = net.sizearr
    zs = [zeros(y, batch_size) for y in sizes[2:end]]
    activations = [zeros(y, batch_size) for y in sizes[2:end]]
    δs = [zeros(y, batch_size) for y in sizes[2:end]]
    batch_tester(batch_size, zs, activations, δs)
end

# forward pass for testing
function (tester::batch_tester)(net::network_v4, x)
    activations = tester.activations
    zs = tester.zs
    len = length(activations)

	input = x
    for i in 1:len
        b, w, z = net.biases[i], net.weights[i], zs[i]
        mul!(z, w, input) # z = w * input
        z .+= b
        activations[i] .= σ.(z)
        input = activations[i]
    end
    return activations[end]
end

# forward and backprop for training
function (trainer::batch_trainer)(net::network_v4, x, y)
    ∇_b = trainer.∇_b
    ∇_w = trainer.∇_w
	len = net.num_layers - 1
    activations = trainer.activations
    zs = trainer.zs
    δs = trainer.δs

    input = x
    for i in 1:len
        b, w, z = net.biases[i], net.weights[i], zs[i]
        mul!(z, w, input) # z = w * input
        z .+= b
        activations[i] .= σ.(z)
        input = activations[i]
    end

    δ = δs[end]
    δ .= (activations[end] .- y) .* σ_grad.(zs[end])
    sum!(∇_b[end], δ)

    for l in 1:len-1
        mul!(∇_w[end-l+1], δ, activations[end-l]') # ∇_w[end-l+1] = δ * activations[end-l]'
        z = zs[end-l]
        mul!(δs[end-l], net.weights[end-l+1]', δ) # δs[end-l] = net.weights[end-l+1]' * δ
        δ = δs[end-l]
        δ .*= σ_grad.(z)
        sum!(∇_b[end-l], δ)
    end
    mul!(∇_w[1], δ, x') # ∇_w[1] = δ * x'

    return nothing
end

function update_batch(net::network_v4, trainer::batch_trainer, x, y)

    trainer(net, x, y)

    coef = trainer.η/size(x,2)
    for i in 1:length(trainer.∇_b)
        net.biases[i] .-= coef .* trainer.∇_b[i]
    end
    for i in 1:length(trainer.∇_w)
        net.weights[i] .-= coef .* trainer.∇_w[i]
    end
end

function SGDtrain(net::network_v4, trainer::batch_trainer, traindata, epochs, tester, testdata=nothing)
    n_test = testdata != nothing ? size(testdata[1], 2) : nothing
    n = size(traindata[1], 2)

    idx = randperm(n) # one time shuffle for performance, then only take random batch index
    # idx = 1:n
    train_x = traindata[1][:,idx]
    train_y = traindata[2][:,idx]
    test_x, test_y = testdata

	batch_size = trainer.batch_size
    # reorganize data in batches
    batch = [(train_x[:, k-batch_size+1 : k], train_y[:, k-batch_size+1 : k]) for k in batch_size:batch_size:n]

    println("========")
    for j in 1:epochs
        idx = randperm(length(batch))

        @time for k in idx
            update_batch(net, trainer, batch[k]...)
        end

        if testdata != nothing
            println("Epoch ", j,": ", evaluate(tester(net, test_x), test_y), "/", tester.batch_size)
        else
            println("Epoch ", j," complete.")
        end
    end
end

function evaluate(out, y)
    hits = 0
    for i = 1:size(out, 2)
        if (findmax(out[:,i])[2] - 1) == y[i]
            hits += 1
        end
    end
    hits
end

function loaddata(rng = 1:60000)
    train_x, train_y = MNIST.traindata(Float64, Vector(rng))
    train_x = reshape(train_x, size(train_x,1)*size(train_x,2), :) # 28 x 28 x N -> 28*28 x N
    train_y = vectorize(train_y)
    test_x, test_y = MNIST.testdata(Float64)
    test_x = reshape(test_x, size(test_x,1)*size(test_x,2), :) # 28 x 28 x N -> 28*28 x N
    return (train_x, train_y), (test_x, test_y)
end

function vectorize(vec)
    N = 10
    len = length(vec)
    mtx = zeros(N, len)
    for i = 1:len
        mtx[vec[i]+1, i] = 1
    end
    return mtx
end

function main_v4()
    epochs = 10
    batch_size = 10
    η = 1.25
    net = network_v4([784, 30, 10])
    traindata, testdata = loaddata()
	trainer = batch_trainer(net, batch_size, η)
	tester = batch_tester(net, size(testdata[1],2))
    SGDtrain(net, trainer, traindata, epochs, tester, testdata)
	# @profiler SGDtrain(net, trainer, traindata, 1, tester, testdata)
end


text:
log_test_batch_begin(type) = print("$type test sets: [")
increment_progress() = print(".")
log_test_batch_end() = println("] ✓")


text:
using LinearAlgebraicRepresentation
Lar = LinearAlgebraicRepresentation
using Plasm, SparseArrays

include("../src/LarSurf.jl")

sz=[3, 3, 3]
sz=[5, 4, 3]
# sz=[1, 2, 3]

# V,(VV,EV,FV,CV) = Lar.cuboidGrid([3,3,3], true)
V,(VV,EV,FV,CV) = Lar.cuboidGrid(sz, true)

# Plasm.view( Plasm.numbering(.6)((V,[VV, EV, FV])) )

faces = LarSurf.get_face_ids_from_cube_in_grid(sz, [2, 2, 2], false)

print(faces)

Plasm.view( Plasm.numbering(.6)((V,[VV, EV, FV])) )

FVfiltered = [FV[faces[i]] for i=1:length(faces)]

Plasm.view( Plasm.numbering(.6)((V,[VV, FVfiltered])) )


text:
# See default_template.jl for an example using this module.

module GeneratorUtils

using DataStructures: OrderedDict
using Printf

export camel_to_snake, exercism_format, expects_error, has_override, override!,
    print_runtests, tighten

const INDENT = ' '^4

"""
    tighten(collection) -> new_collection

Return a new collection with recursively tightened/narrowed container element types.

Starting from the innermost containers and proceeding outward, copy each container `a` into
an array with `collect(x for x in a)`, then apply the constructor for the type of the
`UnionAll` over parameters in `typeof(a)`. This copies the elements into a new container of
appropriate element type (see implementation of `Base.collect`). The original container and
its elements are unchanged.

This is useful for processing output from `JSON.parse`, which returns containers with
element type `Any`. The default output of `show(container)` is much cleaner when the
inferred type based on the elements is identical to the declared element type of the
container.

# Examples
```jldoctest
julia> using GeneratorUtils

julia> a = Pair{Any,Array}(Dict{Any,Tuple}(1 => (2, 3)), Integer[4])
Pair{Any,Array}(Dict{Any,Tuple}(1 => (2, 3)), Integer[4])

julia> tighten(a)
(Dict(1 => (2, 3)), [4])
```
"""
function tighten(a::T) where {T}
    Base.datatype_pointerfree(T) && return a  # not a container
    U = T.name.wrapper  # get the UnionAll over parameters in T
    return U(collect(tighten(x) for x in a))
end

tighten((a, b)::Pair) = (tighten(a), tighten(b))
tighten(a::String) = a

# If we use JSON.parse with OrderedDicts, make each of them look like a Dict when we print
# the tests. We don't want to just convert to a Dict because that removes order information
# which we print out. Note that vectors of OrderedDicts still show as OrderedDict[...]
# because that is dispatched to Base.show with type Vector{OrderedDict}. Out of the 115
# canonical-data.json currently available, Vector{OrderedDict} appears in 6 of them after
# parsing.
function Base.show(io::IO, dict::OrderedDict)
    @printf(io, "Dict(%s)", join(dict, ", "))
end

function exercism_format(x)
    x == [] && return "[]"  # "instead of "Any[]" or "T[]" in general
    return repr(x)  # use repr so that strings are quoted.
end

"""
    print_runtests(io::IO, canonical_data::AbstractDict)

Print the test data from `canonical_data` to `io`.

This first calls `print_header`, then calls `print_test` on every top-level test group in
`canonical_data`. `print_test` in turn calls itself as necessary on each sub-test group.

See (`override!`)[@ref] for a mechanism to override how each test is printed.
```
"""
function print_runtests(io::IO, canonical_data::AbstractDict)
    print_header(io, canonical_data)
    println(io)
    for case in canonical_data["cases"]
        print_test(io, case)
        println(io)
    end
end

"""
    override!(case::AbstractDict; key=value[, ...]) -> case

Override how parts of `case` are printed by the `print_` functions in `GeneratorUtils`.

To remove an entire test, use `delete!` instead on the entry in the parsed JSON.

There are two defaults that often require overrides:
- Using `JSON.jl`, all containers are parsed to `Vector`s and `[Abstract]Dict`s. If you need
  other containers like pairs and tuples, you can, for example, override `lhs` or `test` to
  provide them.
- All arguments are printed as positional arguments with variable names stripped. Again, use
  overrides to change this.

By default, tests are printed like so:

```julia
@testset [description] begin
    # If the test does not expect an error:
    @test [property]([input]...) == [expected]
    # If the test expects an error:
    @test_throws ArgumentError [property]([input]...)
end
```

# Arguments
- `case::AbstractDict`: A case from `canonical-data.json`, parsed into a dictionary (such as
  the output from `JSON.parse`).
- `key=value[, ...]`: A sequence of key-value pairs directing what to override.

# Keywords
The following keywords are currently in use (you can specify any number of them to override
specific parts of `case`):
- `subheader`: Printed just below the top-level header lines.
- `all`: Override an entire test set (should be a multi-line string beginning with
  `"@testset "`). This can be applied at any level (whether a top-level case or a subcase).
    - `description`: Override the description string from `case["description"]`.
    - `setup`: Printed just before a test or test set (e.g., to set up variables).
    - `test`: Override a single test (should be a string beginning with `@test ` or
      `@test_throws `). Defaults to `@test [lhs] == [rhs]` or
      `@test_throws [expected_error] [lhs]`.
        - `lhs`: Expression evaluated in the test. Defaults to `[property]([input])`
            - `property`: See `lhs`.
            - `input`: See `lhs`.
        - `rhs`: Expected output of `lhs`. This is mutually exclusive with `expected_error`.
        - `expected_error`: If `lhs` throws an exception, then this is the exception type.
          Defaults to `ArgumentError`.

# Implementation
Override directives are stored per case in a `Dict{Symbol,Any}` which can be accessed at
`case["override"]`. Methods that wish to use this override mechanism should call `override!`
to insert data, and call `has_override(case[, key])` to determine whether an override
directive exists for the symbol `key`. The interpretation is up to the method.

# Examples
```jldoctest
using GeneratorUtils
test_case = Dict(  # from parsing canonical-data.json
    "description" => "desc",
    "property" => "sqrt",
    "input" => Dict("x" => 81),
    "expected" => 9,
)
GeneratorUtils.print_test(stdout, test_case)
override!(
    test_case;
    description="new " * test_case["description"],
    input="-1",
    expected_error=DomainError,
)
GeneratorUtils.print_test(stdout, test_case)

# output
@testset "desc" begin
    @test sqrt(81) == 9
end
@testset "new desc" begin
    @test_throws DomainError sqrt(-1)
end
```
"""
function override!(case::AbstractDict; keyvals...)
    dict = get!(() -> Dict{Symbol,Any}(), case, "override")
    for (key, val) in keyvals
        dict[key] = val
    end
    return case
end

"""
    has_override(case::AbstractDict[, key::Symbol]) -> Bool

Check whether there is an override defined for symbol `key` in case `case`. If `key` is not
provided, then check whether there is any override at all for the case.
"""
has_override(case::AbstractDict) = haskey(case, "override")
has_override(case, key::Symbol) = has_override(case) && haskey(case["override"], key)

"""
    camel_to_snake(s::AbstractString)

Given a string in camelCase or PascalCase, return a copy in snake_case.
"""
function camel_to_snake(s::AbstractString)
    r = r"(?<!^)(?=[A-Z])"  # (?<!...) is a negative lookbehind, (?=...) is a positive lookahead
    return lowercase(replace(s, r => '_'))
end

"""
    expects_error(case::AbstractDict) -> Bool

Return `true` if the test case `case` expects an error instead of a value. This includes
checking for `expected_error` and `rhs` overrides.
"""
function expects_error(case::AbstractDict)
    return has_override(case, :expected_error) || (
        !has_override(case, :rhs) &&
        case["expected"] isa AbstractDict &&
        haskey(case["expected"], "error")
    )
end

function get_expected_error(case::AbstractDict)
    has_override(case, :expected_error) && return case["override"][:expected_error]
    return ArgumentError  # give a reasonable default if not overridden
end

function get_lhs(case::AbstractDict)
    has_override(case, :lhs) && return case["override"][:lhs]
    property = if has_override(case, :property)
        case["override"][:property]
    else
        camel_to_snake(case["property"])
    end
    input = if has_override(case, :input)
        case["override"][:input]
    else
        join(exercism_format.(values(case["input"])), ", ")
    end
    return @sprintf("%s(%s)", property, input)
end

function get_rhs(case::AbstractDict)
    has_override(case, :rhs) && return case["override"][:rhs]
    return exercism_format(case["expected"])
end

function get_description(case::AbstractDict)
    has_override(case, :description) && return case["override"][:description]
    return case["description"]
end

function print_header(io::IO, canonical_data::AbstractDict)
    @printf(io, "# canonical data version: %s\n", canonical_data["version"])
    print(io, "# This file was generated by a script.\n\n")
    print(io, "using Test\n\n")
    @printf(io, """include("%s.jl")\n""", canonical_data["exercise"])
    has_override(canonical_data, :subheader) && println(io, '\n', canonical_data["override"][:subheader])
end

indent(s::AbstractString) = replace(s, r"^"m => INDENT)

function indent_print(io::IO, f, args...)
    for line in eachline(IOBuffer(sprint(f, args...)))
        println(io, INDENT, line)
    end
end

function print_test(io::IO, case::AbstractDict)
    has_override(case, :all) && return println(io, case["override"][:all])
    @printf(io, """@testset "%s" begin\n""", get_description(case))
    has_override(case, :setup) && println(io, indent(case["override"][:setup]))
    if haskey(case, "cases")  # it's a test group
        for subcase in case["cases"]
            indent_print(io, print_test, subcase)
        end
    else  # it's a single test
        if has_override(case, :test)
            println(io, indent(case["override"][:test]))
        elseif expects_error(case)
            @printf(io, "%s@test_throws %s %s\n", INDENT, get_expected_error(case), get_lhs(case))
        else
            @printf(io, "%s@test %s == %s\n", INDENT, get_lhs(case), get_rhs(case))
        end
    end
    println(io, "end")
end

end


text:
# This is modiried and extended from Eichler et al. code provided by Ashok Litwin-Kumar
# updated to use the newest Julia version (v1.1)

include("learn.jl")
using CSV
using StatsBase
using DataFrames
using Statistics

# the observed connectivity, with first 16 PNs being the community PNs
# (from 190421-process_pnkc_connectivity.py)
ro_conn = convert(Matrix, CSV.read("data/190319-440RDKC_PNfirst16comm_last22blue.csv", header=1)[:,2:end])

Ntrials = 100
Ntrialsper = 3
Nkc = size(ro_conn,1)
Npn = size(ro_conn,2)

# coding level
f = 0.05

# number of odors
P = 10

# standard deviation of Gaussian noise
eps = 0.2

# randomized connectivity based on number of PNs
rd_conn = zeros(size(ro_conn))
for i = 1:size(rd_conn,1)
	t1 = ro_conn[i,:]
	nz = t1[t1.!=0]
	rd_conn[i, sample(1:Npn, length(nz), replace=false)] = nz
end

# observed and random connectivity matrix
J_set = Dict("observed" => ro_conn, "random" => rd_conn)

results = Any[]
for key = ["observed","random"]

	# for observed network, compare between community and non-community
	# for random network, only one (community or non-community is equivilent
	# since connectivity is randomized)
	if key == "observed"
		compare_comm = [true, false]
	else
		compare_comm = true
	end

	J = J_set[key]

	for compare = compare_comm
		err = zeros(Ntrials)
		for ti = 1:Ntrials
			targets = rand(-1:2:1,P)

			if compare

				# in the connectivity matrix, I put the communiy PNs in the first 16 columns, so when activity patterns are given from the first 16 PNs, they are created in the community PNs
				pats = vcat(randn(16,P), zeros(Npn-16, P))
			else

				# otherwise, select 16 PNs from the non-community ones randomly
				pats = zeros(Npn,P)
				pats[rand(17:Npn,16),:]= randn(16,P)

			end
			pats1 = pats + eps*randn(Npn,P)

			pats = (pats .> 0).*pats
			pats1 = (pats1 .> 0).*pats1

			h1 = J*pats1

			thresh = zeros(Nkc)
			mpats1 = zeros(Nkc,P)
			for ci = 1:Nkc
				allh = sort(h1[ci,:])
				thresh[ci] = (allh[floor(Int,(1-f)*length(allh))] + allh[floor(Int,(1-f)*length(allh))+1])/2
				mpats1[ci,:] = (h1[ci,:] .> thresh[ci]) .* (h1[ci,:] .- thresh[ci])
			end

			for mi = 1:Nkc
				mpats1[mi,:] .-= mean(mpats1[mi,:])
			end

			# use the labels (targets) and activity patterns (mpats1) to train the classifier
			wm,bias= quadprogmargin(targets,mpats1)

			for jj = 1:Ntrialsper
				pats2 = pats + eps*randn(Npn,P)
				pats2 = (pats2 .> 0).*pats2
				h2 = J*pats2
				mpats2 = zeros(Nkc,P)

				for ci = 1:Nkc
					mpats2[ci,:] = (h2[ci,:] .> thresh[ci]) .* (h2[ci,:] .- thresh[ci])
				end

				for mi = 1:Nkc
					mpats2[mi,:] .-= mean(mpats2[mi,:])
				end

				# compare predictions by the classifier and same input patterns with different noise realizations
				err[ti] += mean([sign(((mpats2)' * wm .+ bias)[i]) != targets[i] for i in 1:length(targets)])/Ntrialsper

			end
		end

		# it is a binary categorization task, so chance is 0.5
		err[err .> 0.99] .= 0.5

		push!(results,err)

        print(mean(err))
	end
end
results

df = DataFrame(ob_comm=results[1], ob_noncomm=results[2], rd=results[3])

# conclusion (1a): mean(ob_comm) < mean(ob_non_comm)
# conclusion (1b): mean(ob_comm) < mean(rd), only slightly, not robust

# Notes:
# 1) The conclusions are:
#    a) the observed PN-KC connectivity leads to discrimination performance of
#    community input patterns better than that of non-community
#    input patterns;
#    b) compared to random connectivity, the observed PN-KC connectivity
#    leads to slightly better performance in discriminating community input
#    patterns.

# 2) Conclusion (a) is robust. Namely, the difference between mean(ob_comm) and
#    mean(ob_noncomm). However, (b) is NOT robust and only slightly better.

# 3) The comparison may not be equivilent since
#	for ob_comm, it is averaging over the same set of PNs and
#   for ob_noncomm, it is averaging over different set of randomly select PNs.
#   However, I do have a different approach to address this issue
#   (190422_varying_comm_fractions.jl).


text:
# ------------------------------------------------------------------------------
# formatter
# ------------------------------------------------------------------------------
using Pkg
Pkg.add("JuliaFormatter")
using JuliaFormatter

# ------------------------------------------------------------------------------
# run JuliaFormatter
# ------------------------------------------------------------------------------

format(["src", "test", "examples", "docs"])

# ------------------------------------------------------------------------------


text:
@symbol_func function n_rho(cur_reactor::AbstractReactor, cur_rho::AbstractSymbol)
  cur_n_bar = cur_reactor.n_bar

  cur_nu_n = cur_reactor.nu_n

  cur_n_rho = 1 - cur_rho ^ 2

  cur_n_rho ^= cur_nu_n

  cur_n_rho *= cur_n_bar

  cur_n_rho *= 1 + cur_nu_n

  cur_n_rho
end


text:
struct P2D
    x::AbstractMatrix{Real}
    y::AbstractMatrix{Real}

    function P2D(dim1, dim2)
        x = Matrix{Float64}(undef, dim1, dim2)
        fill!(x, 0.)
        y = Matrix{Float64}(undef, dim1, dim2)
        fill!(y, 0.)

        return new(x, y)
    end
end

m = P2D(2, 3)

m.x
m.y

m.x .+= 2.0

function f1(v::P2D, a)
    v.x .+= a
end

f1(m, 3.)


text:
function catch_by_year(Cvec::Vector{<:Catch})
    year_catches = zeros(25)
    year_zeros = zeros(25)
    year_effort = zeros(25)
    for c in Cvec
        year_catches[c.time] += c.catch_biomass
        year_zeros[c.time] += c.catch_biomass == 0
        year_effort[c.time] += c.effort
    end
    year_catches, year_zeros, year_effort
end

function plot_gif(Pvec::Vector{<:PopState}, Cvec::Vector{<:Catch}, file)
    year_catches, _ = catch_by_year(Cvec)
    maxP = maximum(maximum.(getfield.(Pvec, :P)))
    minP = minimum(minimum.(getfield.(Pvec, :P)))
    anim = Animation()
    for yr in 2:25
        plot(heatmap(Pvec[yr].P,
                     color = :viridis, clims = (minP, maxP),
                     aspect_ratio = 1),
             plot(year_catches[1:yr],
                  xlim = (0.5, length(year_catches) + 0.5),
                  ylim = (0.0, 1.05maximum(year_catches))))
        frame(anim)
    end
    gif(anim, file, fps = 5)
end

function plot(Pvec::Vector{<:PopState}, Cvec::Vector{<:Catch})
    stock_status = sum.(Pvec)
    year_catches, _ = catch_by_year(Cvec)
    plot(plot(stock_status, title = "Abundance",
              ylims = (0.0, maximum(stock_status))),
         plot(year_catches, title = "Catch",
              ylims = (0.0, maximum(year_catches))),
         layout = (2, 1), legend = false)
end

function plot(Cvec::Vector{<:Catch})
    year_catches, year_zeros, year_effort = catch_by_year(Cvec)
    plot(plot(year_catches, title = "Catch"),
         plot(year_zeros ./ year_effort, title = "Fraction nonencounters"),
         layout = (2, 1))
end


text:
module FrostHelperGrayBoosterModule

using ..Ahorn, Maple

@mapdef Entity "FrostHelper/GrayBooster" FrostHelperGrayBoosterPlacement(x::Integer, y::Integer, respawnTime::Number=1.0, particleColor::String="Gray", directory="objects/FrostHelper/grayBooster/", reappearSfx::String="event:/game/04_cliffside/greenbooster_reappear", enterSfx::String="event:/game/04_cliffside/greenbooster_enter", boostSfx::String="event:/game/04_cliffside/greenbooster_dash", releaseSfx::String="event:/game/04_cliffside/greenbooster_end", boostTime::Number=0.0, red::Bool=false, dashes::Integer=-1, preserveSpeed::Bool=false)

const colors = sort(collect(keys(Ahorn.XNAColors.colors)))

const placements = Ahorn.PlacementDict(
	"Gray Booster (Frost Helper)" => Ahorn.EntityPlacement(
		FrostHelperGrayBoosterPlacement
	),
	"Gray Booster (Red, Frost Helper)" => Ahorn.EntityPlacement(
		FrostHelperGrayBoosterPlacement,
		"point",
        Dict{String, Any}(),
        function(entity::FrostHelperGrayBoosterPlacement)
			entity.data["red"] = true
            entity.data["directory"] = "objects/FrostHelper/grayBoosterRed/"
			entity.data["reappearSfx"] = "event:/game/05_mirror_temple/redbooster_reappear"
			entity.data["boostSfx"] = "event:/game/05_mirror_temple/redbooster_dash"
			entity.data["enterSfx"] = "event:/game/05_mirror_temple/redbooster_enter"
			entity.data["releaseSfx"] = "event:/game/05_mirror_temple/redbooster_end"
        end
	)
)

Ahorn.editingOptions(entity::FrostHelperGrayBoosterPlacement) = Dict{String, Any}(
    "particleColor" => colors
)

sprite = "objects/booster/booster00"

function Ahorn.selection(entity::FrostHelperGrayBoosterPlacement)
    x, y = Ahorn.position(entity)
    return Ahorn.getSpriteRectangle(sprite, x, y)
end

function Ahorn.render(ctx::Ahorn.Cairo.CairoContext, entity::FrostHelperGrayBoosterPlacement, room::Maple.Room)
	texture = strip(get(entity.data, "directory", "objects/FrostHelper/grayBooster/"), '/')
	realTexture = "$texture/booster00.png"

	Ahorn.drawSprite(ctx, realTexture, 0, 0)
end

end

max_stars_repo_name: JaThePlayer/FrostHelper

max_issues_repo_name: JaThePlayer/FrostHelper

max_forks_repo_name: JaThePlayer/FrostHelper


text:
# This file is auto-generated by AWSMetadata.jl
using AWS
using AWS.AWSServices: lakeformation
using AWS.Compat
using AWS.UUIDs

"""
    BatchGrantPermissions()

Batch operation to grant permissions to the principal.

# Required Parameters
- `Entries`: A list of up to 20 entries for resource permissions to be granted by batch operation to the principal.

# Optional Parameters
- `CatalogId`: The identifier for the Data Catalog. By default, the account ID. The Data Catalog is the persistent metadata store. It contains database definitions, table definitions, and other control information to manage your AWS Lake Formation environment.
"""
batch_grant_permissions(Entries; aws_config::AWSConfig=global_aws_config()) = lakeformation("BatchGrantPermissions", Dict{String, Any}("Entries"=>Entries); aws_config=aws_config)
batch_grant_permissions(Entries, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("BatchGrantPermissions", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Entries"=>Entries), args)); aws_config=aws_config)

"""
    BatchRevokePermissions()

Batch operation to revoke permissions from the principal.

# Required Parameters
- `Entries`: A list of up to 20 entries for resource permissions to be revoked by batch operation to the principal.

# Optional Parameters
- `CatalogId`: The identifier for the Data Catalog. By default, the account ID. The Data Catalog is the persistent metadata store. It contains database definitions, table definitions, and other control information to manage your AWS Lake Formation environment.
"""
batch_revoke_permissions(Entries; aws_config::AWSConfig=global_aws_config()) = lakeformation("BatchRevokePermissions", Dict{String, Any}("Entries"=>Entries); aws_config=aws_config)
batch_revoke_permissions(Entries, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("BatchRevokePermissions", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Entries"=>Entries), args)); aws_config=aws_config)

"""
    DeregisterResource()

Deregisters the resource as managed by the Data Catalog. When you deregister a path, Lake Formation removes the path from the inline policy attached to your service-linked role.

# Required Parameters
- `ResourceArn`: The Amazon Resource Name (ARN) of the resource that you want to deregister.

"""
deregister_resource(ResourceArn; aws_config::AWSConfig=global_aws_config()) = lakeformation("DeregisterResource", Dict{String, Any}("ResourceArn"=>ResourceArn); aws_config=aws_config)
deregister_resource(ResourceArn, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("DeregisterResource", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn), args)); aws_config=aws_config)

"""
    DescribeResource()

Retrieves the current data access role for the given resource registered in AWS Lake Formation.

# Required Parameters
- `ResourceArn`: The resource ARN.

"""
describe_resource(ResourceArn; aws_config::AWSConfig=global_aws_config()) = lakeformation("DescribeResource", Dict{String, Any}("ResourceArn"=>ResourceArn); aws_config=aws_config)
describe_resource(ResourceArn, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("DescribeResource", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn), args)); aws_config=aws_config)

"""
    GetDataLakeSettings()

Retrieves the list of the data lake administrators of a Lake Formation-managed data lake.

# Optional Parameters
- `CatalogId`: The identifier for the Data Catalog. By default, the account ID. The Data Catalog is the persistent metadata store. It contains database definitions, table definitions, and other control information to manage your AWS Lake Formation environment.
"""
get_data_lake_settings(; aws_config::AWSConfig=global_aws_config()) = lakeformation("GetDataLakeSettings"; aws_config=aws_config)
get_data_lake_settings(args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("GetDataLakeSettings", args; aws_config=aws_config)

"""
    GetEffectivePermissionsForPath()

Returns the Lake Formation permissions for a specified table or database resource located at a path in Amazon S3. GetEffectivePermissionsForPath will not return databases and tables if the catalog is encrypted.

# Required Parameters
- `ResourceArn`: The Amazon Resource Name (ARN) of the resource for which you want to get permissions.

# Optional Parameters
- `CatalogId`: The identifier for the Data Catalog. By default, the account ID. The Data Catalog is the persistent metadata store. It contains database definitions, table definitions, and other control information to manage your AWS Lake Formation environment.
- `MaxResults`: The maximum number of results to return.
- `NextToken`: A continuation token, if this is not the first call to retrieve this list.
"""
get_effective_permissions_for_path(ResourceArn; aws_config::AWSConfig=global_aws_config()) = lakeformation("GetEffectivePermissionsForPath", Dict{String, Any}("ResourceArn"=>ResourceArn); aws_config=aws_config)
get_effective_permissions_for_path(ResourceArn, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("GetEffectivePermissionsForPath", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn), args)); aws_config=aws_config)

"""
    GrantPermissions()

Grants permissions to the principal to access metadata in the Data Catalog and data organized in underlying data storage such as Amazon S3. For information about permissions, see Security and Access Control to Metadata and Data.

# Required Parameters
- `Permissions`: The permissions granted to the principal on the resource. AWS Lake Formation defines privileges to grant and revoke access to metadata in the Data Catalog and data organized in underlying data storage such as Amazon S3. AWS Lake Formation requires that each principal be authorized to perform a specific task on AWS Lake Formation resources.
- `Principal`: The principal to be granted the permissions on the resource. Supported principals are IAM users or IAM roles, and they are defined by their principal type and their ARN. Note that if you define a resource with a particular ARN, then later delete, and recreate a resource with that same ARN, the resource maintains the permissions already granted.
- `Resource`: The resource to which permissions are to be granted. Resources in AWS Lake Formation are the Data Catalog, databases, and tables.

# Optional Parameters
- `CatalogId`: The identifier for the Data Catalog. By default, the account ID. The Data Catalog is the persistent metadata store. It contains database definitions, table definitions, and other control information to manage your AWS Lake Formation environment.
- `PermissionsWithGrantOption`: Indicates a list of the granted permissions that the principal may pass to other users. These permissions may only be a subset of the permissions granted in the Privileges.
"""
grant_permissions(Permissions, Principal, Resource; aws_config::AWSConfig=global_aws_config()) = lakeformation("GrantPermissions", Dict{String, Any}("Permissions"=>Permissions, "Principal"=>Principal, "Resource"=>Resource); aws_config=aws_config)
grant_permissions(Permissions, Principal, Resource, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("GrantPermissions", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Permissions"=>Permissions, "Principal"=>Principal, "Resource"=>Resource), args)); aws_config=aws_config)

"""
    ListPermissions()

Returns a list of the principal permissions on the resource, filtered by the permissions of the caller. For example, if you are granted an ALTER permission, you are able to see only the principal permissions for ALTER. This operation returns only those permissions that have been explicitly granted. For information about permissions, see Security and Access Control to Metadata and Data.

# Optional Parameters
- `CatalogId`: The identifier for the Data Catalog. By default, the account ID. The Data Catalog is the persistent metadata store. It contains database definitions, table definitions, and other control information to manage your AWS Lake Formation environment.
- `MaxResults`: The maximum number of results to return.
- `NextToken`: A continuation token, if this is not the first call to retrieve this list.
- `Principal`: Specifies a principal to filter the permissions returned.
- `Resource`: A resource where you will get a list of the principal permissions. This operation does not support getting privileges on a table with columns. Instead, call this operation on the table, and the operation returns the table and the table w columns.
- `ResourceType`: Specifies a resource type to filter the permissions returned.
"""
list_permissions(; aws_config::AWSConfig=global_aws_config()) = lakeformation("ListPermissions"; aws_config=aws_config)
list_permissions(args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("ListPermissions", args; aws_config=aws_config)

"""
    ListResources()

Lists the resources registered to be managed by the Data Catalog.

# Optional Parameters
- `FilterConditionList`: Any applicable row-level and/or column-level filtering conditions for the resources.
- `MaxResults`: The maximum number of resource results.
- `NextToken`: A continuation token, if this is not the first call to retrieve these resources.
"""
list_resources(; aws_config::AWSConfig=global_aws_config()) = lakeformation("ListResources"; aws_config=aws_config)
list_resources(args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("ListResources", args; aws_config=aws_config)

"""
    PutDataLakeSettings()

Sets the list of data lake administrators who have admin privileges on all resources managed by Lake Formation. For more information on admin privileges, see Granting Lake Formation Permissions. This API replaces the current list of data lake admins with the new list being passed. To add an admin, fetch the current list and add the new admin to that list and pass that list in this API.

# Required Parameters
- `DataLakeSettings`: A structure representing a list of AWS Lake Formation principals designated as data lake administrators.

# Optional Parameters
- `CatalogId`: The identifier for the Data Catalog. By default, the account ID. The Data Catalog is the persistent metadata store. It contains database definitions, table definitions, and other control information to manage your AWS Lake Formation environment.
"""
put_data_lake_settings(DataLakeSettings; aws_config::AWSConfig=global_aws_config()) = lakeformation("PutDataLakeSettings", Dict{String, Any}("DataLakeSettings"=>DataLakeSettings); aws_config=aws_config)
put_data_lake_settings(DataLakeSettings, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("PutDataLakeSettings", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("DataLakeSettings"=>DataLakeSettings), args)); aws_config=aws_config)

"""
    RegisterResource()

Registers the resource as managed by the Data Catalog. To add or update data, Lake Formation needs read/write access to the chosen Amazon S3 path. Choose a role that you know has permission to do this, or choose the AWSServiceRoleForLakeFormationDataAccess service-linked role. When you register the first Amazon S3 path, the service-linked role and a new inline policy are created on your behalf. Lake Formation adds the first path to the inline policy and attaches it to the service-linked role. When you register subsequent paths, Lake Formation adds the path to the existing policy. The following request registers a new location and gives AWS Lake Formation permission to use the service-linked role to access that location.  ResourceArn = arn:aws:s3:::my-bucket UseServiceLinkedRole = true  If UseServiceLinkedRole is not set to true, you must provide or set the RoleArn:  arn:aws:iam::12345:role/my-data-access-role

# Required Parameters
- `ResourceArn`: The Amazon Resource Name (ARN) of the resource that you want to register.

# Optional Parameters
- `RoleArn`: The identifier for the role that registers the resource.
- `UseServiceLinkedRole`: Designates an AWS Identity and Access Management (IAM) service-linked role by registering this role with the Data Catalog. A service-linked role is a unique type of IAM role that is linked directly to Lake Formation. For more information, see Using Service-Linked Roles for Lake Formation.
"""
register_resource(ResourceArn; aws_config::AWSConfig=global_aws_config()) = lakeformation("RegisterResource", Dict{String, Any}("ResourceArn"=>ResourceArn); aws_config=aws_config)
register_resource(ResourceArn, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("RegisterResource", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn), args)); aws_config=aws_config)

"""
    RevokePermissions()

Revokes permissions to the principal to access metadata in the Data Catalog and data organized in underlying data storage such as Amazon S3.

# Required Parameters
- `Permissions`: The permissions revoked to the principal on the resource. For information about permissions, see Security and Access Control to Metadata and Data.
- `Principal`: The principal to be revoked permissions on the resource.
- `Resource`: The resource to which permissions are to be revoked.

# Optional Parameters
- `CatalogId`: The identifier for the Data Catalog. By default, the account ID. The Data Catalog is the persistent metadata store. It contains database definitions, table definitions, and other control information to manage your AWS Lake Formation environment.
- `PermissionsWithGrantOption`: Indicates a list of permissions for which to revoke the grant option allowing the principal to pass permissions to other principals.
"""
revoke_permissions(Permissions, Principal, Resource; aws_config::AWSConfig=global_aws_config()) = lakeformation("RevokePermissions", Dict{String, Any}("Permissions"=>Permissions, "Principal"=>Principal, "Resource"=>Resource); aws_config=aws_config)
revoke_permissions(Permissions, Principal, Resource, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("RevokePermissions", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("Permissions"=>Permissions, "Principal"=>Principal, "Resource"=>Resource), args)); aws_config=aws_config)

"""
    UpdateResource()

Updates the data access role used for vending access to the given (registered) resource in AWS Lake Formation.

# Required Parameters
- `ResourceArn`: The resource ARN.
- `RoleArn`: The new role to use for the given resource registered in AWS Lake Formation.

"""
update_resource(ResourceArn, RoleArn; aws_config::AWSConfig=global_aws_config()) = lakeformation("UpdateResource", Dict{String, Any}("ResourceArn"=>ResourceArn, "RoleArn"=>RoleArn); aws_config=aws_config)
update_resource(ResourceArn, RoleArn, args::AbstractDict{String, <:Any}; aws_config::AWSConfig=global_aws_config()) = lakeformation("UpdateResource", Dict{String, Any}(mergewith(_merge, Dict{String, Any}("ResourceArn"=>ResourceArn, "RoleArn"=>RoleArn), args)); aws_config=aws_config)