text:
#---profiling
#=NEW - Profiling
once code is writting, running
we hat to profile it ens then you

1.Start tuning: the performance of code

why: once working, figure out where it spends its time
-Timing the execution is very informative

Takeaway: but as code gets more complicated,

        "Measuring time become Less & Less Useful"

2.start guessing: which part of my code is
 eating up all time (optimize:if you can somehow lower that down)

for that: encourage you to use a set of Profilers

Profiling: what parts of code are Taking part of the time

(in very rough terms) there are two types of profilers:
# instrumenting profiles
an instrument profiler adds measurement 'instrumentation' to your source code

say call f(of x) store results in y: y = f(x) #me: calling f(x) a single variable function

=#
using BenchmarkTools

y = f(x) # this is line

z = g(x, y)

"""
when you run code under instunmenting profiler

it will actually modify that code (effectively)

& run a code looks like this :
"""

push!(timebuffer, ProfileInfo("somefile.jl", 17, time()))
y = f(x)
push!(timebuffer, ProfileInfo("somefile.jl", 18, time()))

z = g(x, y)

push!(timebuffer, ProfileInfo("somefile.jl", 19, time()))

"""basucally it has some buffer that keeps track of timing data
 Right before it runs(first line), it might basically
 Record some information about
1 .where it is (in your source code)
2. what the current time is

then it will make that work
 """

"""
first it knows what time it is
queries the system

(me:simulates time advancesment : by passing i as an argument )
time would have advanced by the function call
(On) every execution, it gets called
that's a very nice way of measuring time

there are a Quite a few profilers, work this way

however,
Insturment profiles come with hurdles:

1.instrumentation slows your code: having to store data at every single function call #TODO: that implements as well in metatrader
2.instumentation can block compiler optimizations: the compiled code of the real version may be quire different from that of the instrumented code "minus instrumentation"
**3.recursion is a bit tricky**: if you also instrument `f`, the added instrumentation inside `f` distorts your measurement of the runtime of `f` itself

so, running code with instrumentation is a very different code, than the code that runs without the instrumentation
you're actually getting a misleading picture of the cirumstances

anytime you do instrumentation inside a function call
has a little instrumentation around it -gets complicated to subtract out ]
costs of insturmentation
world has moved on to a different stle of profiler
"""
i = 17
push!(timebuffer, ProfileInfo("somefile.jl", i, time()))
y = f(x)
push!(timebuffer, ProfileInfo("somefile.jl", i = i + 1, time()))

z = g(x, y)
push!(timebuffer, ProfileInfo("somefile.jl", i = i + 1, time()))

#=Sampling profilers

a sampling profiler ,periodically,
1.interrupts your code and
2. collects program-location data (where you are)

Analogy:

8 hours a day at work
1 hour a day at the gym

real word
waka-time collecting time intervals  of user code activity plus langauge programmed in
 shortcoming: does this 100s times over a month

 aggregates all responses the

 =#
using Makie
# using GLMakie
location = [rand(1:9) <= 8 ? "work" : "gym" for i = 1:1000]

bins = rand(5:16)
#(values = location, bins = bins, normalization = :none) #TODO: hist equivalent (makie)
#("Counts")

using PyPlot

location = [rand]
location = [rand(1:9) <= 8 ? "work" : "gym" for i = 1:1000]

bins = rand(5:16)
hist(values = location; bins = bins, normalization = :none)
ylabels("Counts")

"""
Disadvantages of sampling profilers
1. you don't collect exhuastive information
spending 5 minutses at bank will only be captured at all

2. it's subject to sampling noise (given `n` counts, you have uncertainty
 of approx. `sqrt(n)` counts)

you'll get different number

Advantages of sampling profiler
you're running unmodified code

Code has all the real world optimizations (the compiler can do)

"""

#--deno of profiling

function busywait(t)

        x = 0
        for i = 1:round(Int, 2.1e10 * t)
                x += i % 2
        end
        return x # return `x` to prevent the compiler from noticing that this doesn't do real work & eliminating it
end

@time busywait(0.8) # 8400000000

function mydays(n)
        x = 0
        for i = 1:n
                x += work()
                x += gym()
        end
        return x
end

@noinline work() = busywait(0.08)
@noinline gym() = busywait(0.01)

mydays(1) # run once to compile it #945000000

"""NEW
good rule of thumb:
takeaway: clear the buffer of the library before use

bullet note: the overhead, when the function itself actually is doiing the work

Count  Overhead File                   Line Function
 =====  ======== ====                   ==== ========
  1877         0 @Base\boot.jl           360 eval
  1877         0 @Base\essentials.jl     708 invokelatest(::Any, ::Any, ::...  1877         0 @Base\essentials.jl     708 #invokelatest#2
  1877         0 @Base\essentials.jl     706 invokelatest(::Any, ::Any, ::...  1580      1580 @Base\int.jl             87 +
  1877         0 @Base\loading.jl       1116 include_string(mapexpr::typeo...  1877         0 @Base\logging.jl        603 with_logger
  1877         0 @Base\logging.jl        491 with_logstate(f::Function, lo...  1877         0 @Base\task.jl           411 (::VSCodeServer.var"#53#54")()
     1         1 ...ile\src\Profile.jl   352 stop_timer()
  1580         0 ...torial\profiler.jl   157 busywait
   190        29 ...torial\profiler.jl   174 gym()
  1686         0 ...torial\profiler.jl   167 mydays(n::Int64)
   190         0 ...torial\profiler.jl   168 mydays(n::Int64)
  1686       267 ...torial\profiler.jl   173 work()

me:  count/overhead ratio : for gym :

 190/29 =  6.551724137931034
 1686/267 =  6.314606741573034

work()/gym() ratio:
 267/29 = 9.206896551724138 (over 8 , overworking (seemingly, undergyming)  )
 1686/267 = 6.314606741573034 (under 8, underworking (seemingly over gyming))

from looping at the sampling profiler data

"""

using Profile
Profile.clear() # clear old results (not really needed on the first usuage)
@profile mydays(30)

Profile.print(format = :flat) # represents number of snapshots that it's calling

"""another default way prented in t
 Count  Overhead File                   Line Function
 =====  ======== ====                   ==== ========
  1877         0 @Base\boot.jl           360 eval
  1877         0 @Base\essentials.jl     708 invokelatest(::Any, ::Any, ::...  1877         0 @Base\essentials.jl     708 #invokelatest#2
  1877         0 @Base\essentials.jl     706 invokelatest(::Any, ::Any, ::...  1580      1580 @Base\int.jl             87 +
  1877         0 @Base\loading.jl       1116 include_string(mapexpr::typeo...  1877         0 @Base\logging.jl        603 with_logger
  1877         0 @Base\logging.jl        491 with_logstate(f::Function, lo...  1877         0 @Base\task.jl           411 (::VSCodeServer.var"#53#54")()
     1         1 ...ile\src\Profile.jl   352 stop_timer()
  1580         0 ...torial\profiler.jl   157 busywait
   190        29 ...torial\profiler.jl   174 gym()
  1686         0 ...torial\profiler.jl   167 mydays(n::Int64)
   190         0 ...torial\profiler.jl   168 mydays(n::Int64)
  1686       267 ...torial\profiler.jl   173 work()
  1877         0 ...Server\src\eval.jl   201 (::VSCodeServer.var"#55#59"{V...  1877         0 ...Server\src\eval.jl   124 (::VSCodeServer.var"#56#60"{B...  1877         0 ...Server\src\eval.jl   153 (::VSCodeServer.var"#57#61"{B...  1877         0 ...Server\src\eval.jl   155 (::VSCodeServer.var"#58#62"{B...  1877         0 ...Server\src\eval.jl   211 inlineeval(m::Module, code::S...  1877         0 ...Server\src\eval.jl   209 inlineeval##kw
  1877         0 ...Server\src\eval.jl    34 macro expansion
  1877         0 ...Server\src\repl.jl    36 hideprompt(f::VSCodeServer.va...  1877         0 ...Server\src\repl.jl   185 withpath(f::VSCodeServer.var"...Total snapshots: 1877

Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
    ╎1877 @Base\task.jl:411; (::VSCodeServer.var"#53#54")()
    ╎ 1877 ...Server\src\eval.jl:34; macro expansion
    ╎  1877 @Base\essentials.jl:706; invokelatest(::Any)
    ╎   1877 @Base\essentials.jl:708; #invokelatest#2
    ╎    1877 ...erver\src\eval.jl:201; (::VSCodeServer.var"#55#59"...
    ╎     1877 @Base\logging.jl:603; with_logger
    ╎    ╎ 1877 @Base\logging.jl:491; with_logstate(f::Function...
    ╎    ╎  1877 ...ver\src\eval.jl:124; (::VSCodeServer.var"#56#6...
    ╎    ╎   1877 ...ver\src\repl.jl:36; hideprompt(f::VSCodeServe...
    ╎    ╎    1877 ...ver\src\eval.jl:153; (::VSCodeServer.var"#57#...
    ╎    ╎     1877 ...er\src\repl.jl:185; withpath(f::VSCodeServe...
    ╎    ╎    ╎ 1877 ...er\src\eval.jl:155; (::VSCodeServer.var"#5...
    ╎    ╎    ╎  1877 ...r\src\eval.jl:209; inlineeval##kw
    ╎    ╎    ╎   1877 ...r\src\eval.jl:211; inlineeval(m::Module,...
    ╎    ╎    ╎    1877 ...essentials.jl:706; invokelatest(::Any, :...
    ╎    ╎    ╎     1877 ...ssentials.jl:708; invokelatest(::Any, ...
    ╎    ╎    ╎    ╎ 1877 ...\loading.jl:1116; include_string(mape...
    ╎    ╎    ╎    ╎  1877 @Base\boot.jl:360; eval
   1╎    ╎    ╎    ╎   1    ...\Profile.jl:352; stop_timer()
    ╎    ╎    ╎    ╎   1686 ...profiler.jl:167; mydays(n::Int64)
 267╎    ╎    ╎    ╎    1686 ...profiler.jl:173; work()
    ╎    ╎    ╎    ╎     1419 ...rofiler.jl:157; busywait
1418╎    ╎    ╎    ╎    ╎ 1419 @Base\int.jl:87; +
    ╎    ╎    ╎    ╎   190  ...profiler.jl:168; mydays(n::Int64)
  29╎    ╎    ╎    ╎    190  ...profiler.jl:174; gym()
    ╎    ╎    ╎    ╎     161  ...rofiler.jl:157; busywait
 161╎    ╎    ╎    ╎    ╎ 161  @Base\int.jl:87; +
Total snapshots: 1877

1686/ 1877 = 0.89824

Takeaway: in profiler tree: the indentation indicates who called `whom`

Information is attributed to the entire call sequence
(aggregated in al time spent in that particular line of code )

different way of checking, it doesn't take a different amount of time

TODO:
Q. what is an overhead, & overcount #Research

u

"""
Profile.print(format = :tree)

#--visualization of profile data

using ProfileView # `ProfileView` for real work instead

ProfileView.view()

#= on jupyter only
using ProfileSVG

ProfileSVG.view()
=#
#--- Performace profiling in action
#=
Discovering an opportunity for an optimization
 by a profile

=#

#Data definition

A = rand(10_000, 2)
B = rand(2, 8_000)
x = rand(8_000)
function mult(A, B, x)
        C = A * B
        return C * x
end

mult(A, B, x)

@time mult(A, B, x)  # 0.500144 seconds #2.57 M allocations: 748.353 MiB, 4.44% gc time, 77.02% compilation time
using ProfileSVG
#Error:@profview is undefined - which macro is it from?
@profview mult(A, B, x)

"""
(always) know what to look for!
it's revealing this 'gemm' where
mm is matrix multiply
mv: matrix vectore (multiply)

most of time spent (lost) multiplying those matrices
-Going back above, 'C' is a matrix multiplication -
thus, a bottle is easily spottable, now

what if:
1.we do the matrix multiplication, first
2. do a Second matrix-vector multiplication
"""
function mult2(A, B, x)

        y = B * x
        return A * y

end

# the use of \approx or ≈
mult2(A, B, x) ≈ mult(A, B, x) #they are approx. equal
mult2(A, B, x) == mult(A, B, x) # but they wont ever be equal
error = mult2(A, B, x) - mult(A, B, x)
#= ME:
critical side-note:
this introduces an unexpected  systematic model error
=#
"""Tim Holy
here the error is small,
there's a need for a hight precision
so, to a very high-degree of precision , these two are equal
(to ecach other )
me: discarding the error, as if it doesn't exist
like blinding turning an eye on it
it won't help much

"""

@time mult2(A, B, x) #0.000718 seconds (3allocations:78.297KiB)

#=we've made a dramatic  Improvement on the matrix multipkucatuib

=#
#--- Using profiling to detect "gotchas"

#=
Recall the addTwo was slopw when passed a `Vector{Any}`
but fast for a `Vector{T}` with concrete `T``
=#
#= 0.001 ns (0 allocations: 0 bytes)
(:
:var"#addTwo#5") (generic function with 1 method)=#
@btime addTwo(z) = (x = rand(1:5); y = rand(1:5); z = [x, y])

#=  0.001 ns (0 allocations: 0 bytes)
(::var"#addTwo#6") (generic function with 1 method) =#
@btime addTwo(z) = (x = rand(1:5); y = rand(1:5); z = Any[x, y])

"""Any type makes  running code longer
Q. what if i did it on accident, what should I do now?

sometimes you'll be surpised about the code you write that breaks type-Inference

#BenchmarkTools have a macro  @bprofile
Why: to collect profile Data on (code)
me: outputs statistics of  a 10K samples,  1K evaluations
"""

@bprofile addTwo(z) = (x = rand(1:5); y = rand(1:5); z = Any[x, y])

"""

BenchmarkTools.Trial: 10000 samples with 1000 evaluations.
 Range (min … max):  0.001 ns … 1.400 ns  ┊ GC (min …
max): 0.00% … 0.00%
 Time  (median):     0.001 ns             ┊ GC (median):    0.00%
 Time  (mean ± σ):   0.043 ns ± 0.053 ns  ┊ GC (mean ± σ):  0.00% ± 0.00%

  █
    ▄
  █▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁█ ▂
  0.001 ns       Histogram: frequency by time        0.1 ns <

 Memory estimate: 0 bytes, allocs estimate: 0.

 involving strings,
 comes from times operation on code
 prints in REPL all type info & method instumentationif right click on it
 it takes you to the code

 all its copying going on

 the Hint: the copying (hat's going on)
 we're starting of fwith an empty string
 2. we're going char by char
 3. the, you add another Whole character to a string
 -it's gonna have to copy the old string, with a little extrra space on the end (then the character)
 """

using Profile, ProfileSVG, ProfileView, BenchmarkTools
const charlist = 'a':'z' #Global Variable # define as const #

function randomstring(n::Integer)
        str = ""
        for i = 1:n
                str *= rand(charlist)
        end
        return str
end

"""preallocate is  the answer
Instead, preallocate some Memory

after applying changes, check if it's working, as expected before
"""

function randomstring2(n::Integer)
        # preallocate some Memory
        chars = Vector{UInt8}(undef, n)
        #preallocate a buffer for this
        #instead of growing it each time , simply stash the random variable
        for i = 1:n
                chars[i] = rand(charlist) #stash the chars (me:1 by 1)
        end
        #return str
        return String(chars)
end

function randomstring3(n::Integer)
        # preallocate some Memory
        chars = Vector{UInt8}(undef, n)#local variable #how did he know that, is scope is this function only, isn't that enough to make it local
        #preallocate a buffer for this
        #instead of growing it each time , simply stash the random variable
        for i = 1:n
                chars[i] = rand(charlist) #stash the chars (me:1 by 1)
        end
        #return str
        return String(chars)
end

ProfileSVG.view() #initializes ProfileView

randomstring(8)
@time randomstring(10^5);#4.639694 seconds (300.00 k allocations: 4.672 GiB, 16.61% gc time)

randomstring2(8)
@time randomstring2(10^5); #in REPL #0.008138 seconds (99.49 k allocations: 1.709 MiB)

ProfileView.@view()
warntype_last #warntype at last thi clickedd onsa
@time randomstring3(10^5); # global vairable charlist # 0.063154 seconds (155.18 k allocations: 4.939 MiB, 85.53% compilation time)
 #=first page on the ma
 return
 main.charlist is a global variable
  & not constant
  since it's not constant - it change the type
  any moment
  so, julia can't create an optimized version
  of this function with Fixed height (length)
 for charlist

one point of View: it could be multi-threaded (we could change its type)
takeaway: we can change type of code of fuliea
while the code is running

        so, that would be really bad if it would hit
        hard wired-in Known Type, & that type change
       that would be really problematic
if wanna fix  the performance , the way you can do it, declare this list constant

Takeaway: for any project, determine list of constants, for them to be preallocated each time the project loads
that will saved from problems & code performace issues
        =#

#=
looking at the second method
what is that line red ?
-it's doing dispatch
 profile View's other feature
 it'll show you code Type, or specialized color version
 @code_warn_type (warntype_last()../6) (outputs shows which line) on the last thing you clicked on
=#

#=
julia can be fast, but you need to learn enought to avoid some common gotchas
1. don't use non-`const` global variables
2. don't use containers like arrays with non-concrete types (unless absolutely necessary)
3. measure & analyze performance with @time, BenchmarkTools,`@Profile`, `@bProfile`,ProfileView
=#
#===end of profiling optimization part 1=====

ext: jl

max_stars_repo_path: Tutorial/Tim Holy/profiler.jl

max_stars_repo_name: adamwillisMastery/DeepLearner

max_issues_repo_path: Tutorial/Tim Holy/profiler.jl

max_issues_repo_name: adamwillisMastery/DeepLearner

max_forks_repo_path: Tutorial/Tim Holy/profiler.jl

max_forks_repo_name: adamwillisXanax/DeepLearner


text:
using JuMP, EAGO

                     m = Model()

                     EAGO.register_eago_operators!(m)

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

                     @variable(m, -14.06559781669544 <= q <= 13.37751741699121)

                     add_NL_constraint(m, :((-0.7556338259975872 + -0.2850076752045205*(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + -0.5819748667402531*(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + 0.4871037750371179*(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))))/(1 + exp(-(-0.7556338259975872 + -0.2850076752045205*(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + -0.5819748667402531*(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + 0.4871037750371179*(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))))))) + (0.9186311390475046 + -0.8559712370251158*(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + -0.2512416329037399*(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + 0.7592758779705528*(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))))/(1 + exp(-(0.9186311390475046 + -0.8559712370251158*(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + -0.2512416329037399*(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + 0.7592758779705528*(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))))))) + (-0.7151630404444922 + -0.15417874070690862*(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + -0.016895941959414795*(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + -0.17047547651198514*(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))))/(1 + exp(-(-0.7151630404444922 + -0.15417874070690862*(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.7432962759699406 + 0.616365769922441*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + -0.9563519707270385*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.21036883565748976*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + -0.016895941959414795*(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.6367931081099356 + 0.08862555157308405*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.5030828808953012*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + -0.4316150506981855*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))))))) + -0.17047547651198514*(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5])))))/(1 + exp(-(0.12597161846431115 + 0.10770543162761159*(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5]))/(1 + exp(-(-0.4636854780986108 + 0.31515700957585446*$(x[1]) + 0.3880835610738931*$(x[2]) + 0.5564947842471106*$(x[3]) + -0.6707203467350809*$(x[4]) + 0.9006732364765586*$(x[5])))) + 0.46799585735795457*(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5]))/(1 + exp(-(0.08793534010659565 + 0.5972587053731475*$(x[1]) + 0.5980877634648243*$(x[2]) + 0.5697895882823776*$(x[3]) + -0.6631393507177727*$(x[4]) + -0.46226121533035425*$(x[5])))) + 0.45029698767672954*(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(x[5]))/(1 + exp(-(-0.49150226791798435 + -0.92821223742826*$(x[1]) + -0.3666783267897977*$(x[2]) + -0.7302712314714839*$(x[3]) + 0.924313656245149*$(x[4]) + 0.3686570879245057*$(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:
using Test, MLJModelInterface
using ScientificTypes, MLJScientificTypes
using Tables, Distances, CategoricalArrays, InteractiveUtils
import DataFrames: DataFrame

const M  = MLJModelInterface
const FI = M.FullInterface
ScientificTypes.TRAIT_FUNCTION_GIVEN_NAME[:table] = Tables.istable

setlight() = M.set_interface_mode(M.LightInterface())
setfull()  = M.set_interface_mode(M.FullInterface())

include("mode.jl")
include("parameter_inspection.jl")
include("data_utils.jl")
include("metadata_utils.jl")
include("model_def.jl")
include("model_api.jl")
include("model_traits.jl")
include("equality.jl")


text:
using ImageFiltering, ImageCore, OffsetArrays, Colors, FFTViews, ColorVectorSpace, ComputationalResources, FixedPointNumbers
using LinearAlgebra
using Test
using ImageFiltering: IdentityUnitRange

@testset "tiling" begin
    m = zeros(UInt8, 20, 20)
    for i = -2:2; m[diagind(m,i)] .= 0xff; end
    kernel = KernelFactors.prewitt((true,true), 1)
    kp = broadcast(*, kernel...)
    # target is the result we want to get
    target = zeros(20, 20)
    dv = [42.5, 85, 85, 42.5]
    for i = 1:4
        target[diagind(target, i)] .= dv[i]
        target[diagind(target, -i)] .= -dv[i]
    end
    mf = imfilter(m, kernel)
    @test mf[2:19, 2:19] ≈ target[2:19, 2:19]
    for r in (CPU1(Algorithm.FIR()), CPU1(Algorithm.FIRTiled()),
              CPUThreads(Algorithm.FIR()), CPUThreads(Algorithm.FIRTiled()))
        mf = @inferred(imfilter(r, m, kernel))
        @test mf[2:19, 2:19] ≈ target[2:19, 2:19]
    end
    mf = imfilter(m, (kp,))
    @test mf[2:19, 2:19] ≈ target[2:19, 2:19]
    # A big image
    img = rand(1000,999)
    kf = kernelfactors((rand(7), rand(7)))
    k = broadcast(*, kf...)
    imgf = imfilter(m, k, Algorithm.FIR())
    for r in (CPU1(Algorithm.FIR()), CPU1(Algorithm.FIRTiled()),
              CPUThreads(Algorithm.FIR()), CPUThreads(Algorithm.FIRTiled()))
        @test imfilter(r, m, kf) ≈ imgf
    end
end

@testset "FIR/FFT" begin
    f32type(img) = f32type(eltype(img))
    f32type(::Type{C}) where {C<:Colorant} = base_colorant_type(C){Float32}
    f32type(::Type{T}) where {T<:Number} = Float32
    zerona!(a) = (a[isnan.(a)] .= zero(eltype(a)); a)
    zerona!(a, nanflag) = (a[nanflag] .= zero(eltype(a)); a)
    ## Images for which the boundary conditions will be irrelevant
    imgf = zeros(5, 7); imgf[3,4] = 1
    imgi = zeros(Int, 5, 7); imgi[3,4] = 1
    imgg = fill(Gray{N0f8}(0), 5, 7); imgg[3,4] = 1
    imgc = fill(RGB{N0f8}(0,0,0), 5, 7); imgc[3,4] = RGB(1,0,0)
    # Dense inseparable kernel
    kern = [0.1 0.2; 0.4 0.5]
    kernel = OffsetArray(kern, -1:0, 1:2)
    for img in (imgf, imgi, imgg, imgc)
        targetimg = zeros(typeof(img[1]*kern[1]), size(img))
        targetimg[3:4,2:3] = rot180(kern) .* img[3,4]
        @test @inferred(imfilter(img, kernel)) ≈ targetimg
        @test @inferred(imfilter(img, (kernel,))) ≈ targetimg
        @test @inferred(imfilter(f32type(img), img, kernel)) ≈ float32.(targetimg)
        ret = imfilter(img, kernel)
        fill!(ret, zero(eltype(ret)))
        @test @inferred(imfilter!(ret, img, kernel)) ≈ targetimg
        fill!(ret, zero(eltype(ret)))
        @test @inferred(imfilter!(CPU1(Algorithm.FIR()), ret, img, kernel)) ≈ targetimg
        for border in ("replicate", "circular", "symmetric", "reflect", Fill(zero(eltype(img))))
            @test @inferred(imfilter(img, kernel, border)) ≈ targetimg
            @test @inferred(imfilter(f32type(img), img, kernel, border)) ≈ float32.(targetimg)
            fill!(ret, zero(eltype(ret)))
            @test @inferred(imfilter!(ret, img, kernel, border)) ≈ targetimg
            for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
                @test @inferred(imfilter(img, kernel, border, alg)) ≈ targetimg
                @test @inferred(imfilter(img, (kernel,), border, alg)) ≈ targetimg
                @test @inferred(imfilter(f32type(img), img, kernel, border, alg)) ≈ float32.(targetimg)
                fill!(ret, zero(eltype(ret)))
                @test @inferred(imfilter!(CPU1(alg), ret, img, kernel, border)) ≈ targetimg
            end
            @test_throws MethodError imfilter!(CPU1(Algorithm.FIR()), ret, img, kernel, border, Algorithm.FFT())
        end
        targetimg_inner = OffsetArray(targetimg[2:end, 1:end-2], 2:5, 1:5)
        @test @inferred(imfilter(img, kernel, Inner())) ≈ targetimg_inner
        @test @inferred(imfilter(f32type(img), img, kernel, Inner())) ≈ float32.(targetimg_inner)
        for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
            @test @inferred(imfilter(img, kernel, Inner(), alg)) ≈ targetimg_inner
            @test @inferred(imfilter(f32type(img), img, kernel, Inner(), alg)) ≈ float32.(targetimg_inner)
            @test @inferred(imfilter(CPU1(alg), img, kernel, Inner())) ≈ targetimg_inner
        end
    end
    # Factored kernel
    kernel = (OffsetArray([0.2,0.8], -1:0), OffsetArray([0.3 0.6], 0:0, 1:2))
    kern = parent(kernel[1]).*parent(kernel[2])
    for img in (imgf, imgi, imgg, imgc)
        targetimg = zeros(typeof(img[1]*kern[1]), size(img))
        targetimg[3:4,2:3] = rot180(kern) .* img[3,4]
        ret = similar(targetimg)
        @test @inferred(imfilter(img, kernel)) ≈ targetimg
        @test @inferred(imfilter(f32type(img), img, kernel)) ≈ float32.(targetimg)
        for border in ("replicate", "circular", "symmetric", "reflect", Fill(zero(eltype(img))))
            @test @inferred(imfilter(img, kernel, border)) ≈ targetimg
            @test @inferred(imfilter(f32type(img), img, kernel, border)) ≈ float32.(targetimg)
            for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
                @test @inferred(imfilter(img, kernel, border, alg)) ≈ targetimg
                @test @inferred(imfilter(f32type(img), img, kernel, border, alg)) ≈ float32.(targetimg)
            end
            @test_throws MethodError imfilter!(CPU1(Algorithm.FIR()), ret, img, kernel, border, Algorithm.FFT())
        end
        targetimg_inner = OffsetArray(targetimg[2:end, 1:end-2], 2:5, 1:5)
        @test @inferred(imfilter(img, kernel, Inner())) ≈ targetimg_inner
        @test @inferred(imfilter(f32type(img), img, kernel, Inner())) ≈ float32.(targetimg_inner)
        for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
            @test @inferred(imfilter(img, kernel, Inner(), alg)) ≈ targetimg_inner
            @test @inferred(imfilter(f32type(img), img, kernel, Inner(), alg)) ≈ float32.(targetimg_inner)
        end
    end
    # Rational filter coefficients
    kernel = (centered([1//3, 1//3, 1//3]), centered([1//3, 1//3, 1//3]'))
    kern = kernel[1].*kernel[2]
    for img in (imgf, imgi, imgg, imgc)
        targetimg = zeros(typeof(img[1]*kern[1]), size(img))
        targetimg[2:4,3:5] .= img[3,4]*(1//9)
        @test @inferred(imfilter(img, kernel)) ≈ targetimg
        @test @inferred(imfilter(f32type(img), img, kernel)) ≈ float32.(targetimg)
        for border in ("replicate", "circular", "symmetric", "reflect", Fill(zero(eltype(img))))
            @test @inferred(imfilter(img, kernel, border)) ≈ targetimg
            @test @inferred(imfilter(f32type(img), img, kernel, border)) ≈ float32.(targetimg)
            for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
                if alg == Algorithm.FFT() && eltype(img) == Int
                    @test @inferred(imfilter(Float64, img, kernel, border, alg)) ≈ targetimg
                else
                    @test @inferred(imfilter(img, kernel, border, alg)) ≈ targetimg
                end
                @test @inferred(imfilter(f32type(img), img, kernel, border, alg)) ≈ float32.(targetimg)
            end
        end
        targetimg_inner = OffsetArray(targetimg[2:end-1, 2:end-1], 2:4, 2:6)
        @test @inferred(imfilter(img, kernel, Inner())) ≈ targetimg_inner
        @test @inferred(imfilter(f32type(img), img, kernel, Inner())) ≈ float32.(targetimg_inner)
        for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
            if alg == Algorithm.FFT() && eltype(img) == Int
                @test @inferred(imfilter(Float64, img, kernel, Inner(), alg)) ≈ targetimg_inner
            else
                @test @inferred(imfilter(img, kernel, Inner(), alg)) ≈ targetimg_inner
            end
            @test @inferred(imfilter(f32type(img), img, kernel, Inner(), alg)) ≈ float32.(targetimg_inner)
        end
    end
    ## Images for which the boundary conditions matter
    imgf = zeros(5, 7); imgf[1,2] = 1
    imgi = zeros(Int, 5, 7); imgi[1,2] = 1
    imgg = fill(Gray(0), 5, 7); imgg[1,2] = 1
    imgc = fill(RGB(0,0,0), 5, 7); imgc[1,2] = RGB(1,0,0)
    # Dense kernel
    kern = [0.1 0.2; 0.4 0.5]
    kernel = OffsetArray(kern, -1:0, 1:2)
    function target1(img::AbstractArray{T}, kern, border) where T
        if border ∈ ("replicate", "symmetric")
            ret = float64.(zero(img))
            x = img[1,2]
            ret[1,1] = (kern[1,1]+kern[2,1])*x
            ret[2,1] = kern[1,1]*x
            ret
        elseif border == "circular"
            a = FFTView(float64.(zero(img)))
            x = img[1,2]
            a[0:1, -1:0] = rot180(kern).*x
            parent(a)
        elseif border == "reflect" || isa(border, Fill)
            ret = float64.(zero(img))
            x = img[1,2]
            ret[1,1] = kern[2,1]*x
            ret[2,1] = kern[1,1]*x
            ret
        end
    end
    function target1(img::AbstractArray{T}, kern, ::NA) where T
        ret = float64.(zero(img))
        x = img[1,2]
        ret[1,1] = kern[2,1]*x/(kern[2,1]+kern[2,2])
        ret[2,1] = kern[1,1]*x/sum(kern)
        ret[:,end] .= nan(eltype(ret))  # for the last column, this kernel is entirely in the padding region
        ret
    end
    for img in (imgf, imgi, imgg, imgc)
        for border in ("replicate", "circular", "symmetric", "reflect", Fill(zero(eltype(img))))
            targetimg = target1(img, kern, border)
            @test @inferred(imfilter(img, kernel, border)) ≈ targetimg
            @test @inferred(imfilter(f32type(img), img, kernel, border)) ≈ float32.(targetimg)
            for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
                @test @inferred(imfilter(img, kernel, border, alg)) ≈ targetimg
                @test @inferred(imfilter(f32type(img), img, kernel, border, alg)) ≈ float32.(targetimg)
            end
        end
        border = NA()
        targetimg0 = target1(img, kern, border)
        nanflag = isnan.(targetimg0)
        targetimg = zerona!(copy(targetimg0))
        @test @inferred(zerona!(imfilter(img, kernel, border))) ≈ targetimg
        @test @inferred(zerona!(imfilter(f32type(img), img, kernel, border))) ≈ float32.(targetimg)
        for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
            @test @inferred(zerona!(imfilter(img, kernel, border, alg), nanflag)) ≈ targetimg
            @test @inferred(zerona!(imfilter(f32type(img), img, kernel, border, alg), nanflag)) ≈ float32.(targetimg)
        end
    end
    # Factored kernel
    kernel = (OffsetArray([0.2,0.8], -1:0), OffsetArray([0.3 0.6], 0:0, 1:2))
    kern = parent(kernel[1]).*parent(kernel[2])
    for img in (imgf, imgi, imgg, imgc)
        for border in ("replicate", "circular", "symmetric", "reflect", Fill(zero(eltype(img))))
            targetimg = target1(img, kern, border)
            @test @inferred(imfilter(img, kernel, border)) ≈ targetimg
            @test @inferred(imfilter(f32type(img), img, kernel, border)) ≈ float32.(targetimg)
            for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
                @test @inferred(imfilter(img, kernel, border, alg)) ≈ targetimg
                @test @inferred(imfilter(f32type(img), img, kernel, border, alg)) ≈ float32.(targetimg)
            end
        end
        border = NA()
        targetimg0 = target1(img, kern, border)
        nanflag = isnan.(targetimg0)
        targetimg = zerona!(copy(targetimg0))
        @test @inferred(zerona!(imfilter(img, kernel, border))) ≈ targetimg
        @test @inferred(zerona!(imfilter(f32type(img), img, kernel, border))) ≈ float32.(targetimg)
        for alg in (Algorithm.FIR(), Algorithm.FIRTiled(), Algorithm.FFT())
            @test @inferred(zerona!(imfilter(img, kernel, border, alg), nanflag)) ≈ targetimg
            @test @inferred(zerona!(imfilter(f32type(img), img, kernel, border, alg), nanflag)) ≈ float32.(targetimg)
        end
    end
    # filtering with a 0d kernel
    a = rand(3,3)
    # @test imfilter(a, reshape([2])) ≈ 2a
    # imfilter! as a copy
    ret = zeros(3, 3)
    b = @inferred(imfilter!(CPU1(Algorithm.FIR()), ret, a, (), NoPad()))
    @test b == a
    @test !(b === a)
    # OffsetArrays
    img = OffsetArray(rand(RGB{N0f8}, 80, 100), (-5, 3))
    imgf = imfilter(img, Kernel.gaussian((3,3)))
    @test axes(imgf) == axes(img)
end

@testset "Borders (issue #85)" begin
    A = ones(8, 8)
    r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0))
    r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0, (3,3)))
    r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10, (3,3)))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0, (3,3),(3,3)))
    r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10, (3,3), (3,3)))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0, [3,3],[3,3]))
    r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10, [3,3], [3,3]))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(0, Kernel.gaussian((1,1),(3,3))))
    r2 = imfilter(A, Kernel.gaussian((1,1),(3,3)), Fill(10, Kernel.gaussian((1,1),(3,3))))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    B = fill!(similar(A), 0)
    C = fill!(similar(A), 0)
    r1 = imfilter!(B, A, Kernel.gaussian((1,1),(3,3)), Fill(0))
    r2 = imfilter!(C, A,  Kernel.gaussian((1,1),(3,3)), Fill(10))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    fill!(B, 0); fill!(C, 0)
    r1 = imfilter!(B, A, Kernel.gaussian((1,1),(3,3)), Fill(0, (3,3)))
    r2 = imfilter!(C, A,  Kernel.gaussian((1,1),(3,3)), Fill(10, (3,3)))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    fill!(B, 0); fill!(C, 0)
    r1 = imfilter!(B, A, Kernel.gaussian((1,1),(3,3)), Fill(0, (3,3),(3,3)))
    r2 = imfilter!(C, A,  Kernel.gaussian((1,1),(3,3)), Fill(10, (3,3),(3,3)))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    fill!(B, 0); fill!(C, 0)
    r1 = imfilter!(B, A, Kernel.gaussian((1,1),(3,3)), Fill(0, [3,3],[3,3]))
    r2 = imfilter!(C, A,  Kernel.gaussian((1,1),(3,3)), Fill(10, [3,3],[3,3]))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    g = collect(KernelFactors.gaussian(1,3))
    r1 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(0))
    r2 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(10))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(0, (3,3)))
    r2 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(10, (3,3)))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(0, (3,3),(3,3)))
    r2 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(10, (3,3),(3,3)))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(0, [3,3],[3,3]))
    r2 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(10, [3,3],[3,3]))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(0))
    r2 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,0}(centered(g)),), Fill(10))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,1}(centered(g)),), Fill(0, (3,3)))
    r2 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,1}(centered(g)),), Fill(10, (3,3)))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,1}(centered(g)),), Fill(0, (3,3),(3,3)))
    r2 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,1}(centered(g)),), Fill(10, (3,3),(3,3)))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    r1 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,1}(centered(g)),), Fill(0, [3,3],[3,3]))
    r2 = imfilter(A, ( ImageFiltering.ReshapedOneD{2,1}(centered(g)),), Fill(10, [3,3],[3,3]))
    @test r1[4,4] == r2[4,4]
    @test r1[1,1] != r2[1,1]

    err = ArgumentError("Fill{$Int,1}(0, (3,), (3,)) lacks the proper padding sizes for an array with 2 dimensions")
    kern = Kernel.gaussian((1,1),(3,3))
    @test_throws err imfilter(A, kern, Fill(0, (3,)))
    kernf = ImageFiltering.factorkernel(kern)
    err = DimensionMismatch("requested indices (1:8, 0:9) and kernel indices $(axes(kernf[1])) do not agree with indices of padded input, $((IdentityUnitRange(0:9), IdentityUnitRange(1:8)))")
    @test_throws err imfilter(A, kern, Fill(0, (1,0)))
    @test_throws DimensionMismatch imfilter(A, kern, Fill(0, (0,1)))
    @test_throws DimensionMismatch imfilter(A, kern, Fill(0, (0,0)))
end


text:
# jobsequencial.jl
"""
sequencial job table handling
"""

using LinearAlgebra, Statistics
using Random
using DataFrames

# create list of jobnumbers using proc table
# example
# lst = [2,3,3] ==> [1,1,2,2,2,3,3,3]
function joblist(lst)
    a = Array{Int,1}()
    for i in 1:length(lst)
        append!(a,repeat([i],lst[i]))
    end
    a
end

# make job time table base (ignoring sequence)
function jobtablebase(ptable::Array{Int,2})
    sz = size(ptable)
    lp = sum(ptable)

    tb = DVector{Int}()
    for i in 1:sz[1]
        jl = joblist(ptable[i,:])
        lst = vcat(jl,zeros(Int,lp - length(jl)))
        push!(tb,lst)
    end
    tb
end

# return set of grouping number for given list
function getgroups(lst)
    gs = Int[]
    for gp in grouptable
        g = gp[:grp]
        for x in lst
            if x in gp[:id]
                push!(gs,g)
            end
        end
    end
    Set(gs)
end

function evolutecross!(pptbl::Array{DVector{Int},1}, survival=0.8, elite=0.2, mutant=0.05)
    s0 = length(pptbl)
    sortpopulation!(pptbl)
    survive!(pptbl,survival)
    s = length(pptbl)
    en = Int(round(elite*s))

    k = (s0-s)
    while k > 0
        if rand() < elite
            i1 = rand(1:en)
            i2 = rand(1:en)
        else
            i1 = rand(1:s)
            i2 = rand(1:s)
        end

        c1,c2 = crossover(pptbl[i1],pptbl[i2])
        if rand() < mutant
            swapjobrow!(c1)
            swapjobrow!(c2)
        end
        push!(pptbl,c1)
        push!(pptbl,c2)
        k -= 2
    end
    v = penalty.(pptbl)
    [minimum(v),Int(round(median(v))),maximum(v)]
end

function seqevolution!(pptbl::Array{DVector{Int},1}, n::Int, nr=10, survival=0.8, elite=0.2, mutant=0.05; stopat = 0)
    rep = DVector{Int}()

    for i in 1:n
        # sortjob!.(pptbl)
        # sortjobcol!.(pptbl)
        dt = evolutecross!(pptbl,survival,elite,mutant)
        push!(rep,dt)

        if i % nr == 0
            println("i:$i => $dt")
        end
        if dt[1] <= stopat
            break
        end
    end
    rep
end

# give exclusive group duplication penalty
# function grdupenalty(jtbl::Array{Int,2})
#     p = 0
#     for j in 1:validlength(jtbl)
#         lst = jtbl[:,j]
#         x = length(getgroups(lst))
#         p += ( x>1 ? (x-1) : 0 )
#     end
#     p
# end

# give if duplicate occurs at not groupable item
# function listduplicate(jtbl::Array{Array{Int,1},1}, glst::Array{Int,1})

#     p = zeros(Int,length(jtbl[1]))
#     for i in 1:validlength(jtbl)
#         col = coltake(jtbl,i)
#         cc = []
#         for c in col
#             if !(c in glist)
#                 push!(cc,c)
#             end
#         end

#         cs = Set(cc)
#         p[i] = (length(cc) - length(cs))
#     end
#     [p for x in jtbl]
# end

max_stars_repo_name: Yoshinobu-Ishizaki/ProcGA

max_issues_repo_name: Yoshinobu-Ishizaki/ProcGA

max_forks_repo_name: Yoshinobu-Ishizaki/ProcGA


text:
using BenchmarkTools
using LinearAlgebra

function progonka!(u,a,b,c,f)
    N = size(f,1)
    α=similar(f)
    β=similar(f)
    α[2] = -c[1]/b[1]
    β[2] = f[1]/b[1]
    @inbounds @fastmath for i in 2:N-1 #Forward Sweep
        α[i+1]=-c[i]/(a[i-1]*α[i]+b[i])
        β[i+1]=(f[i]-a[i-1]*β[i])/(a[i-1]*α[i]+b[i])
    end
    u[N]=(f[N]-a[N-1]*β[N])/(a[N-1]*α[N]+b[N])
    @inbounds @fastmath for i in N-1:-1:1 #Backward Sweep
        u[i]=α[i+1]*u[i+1]+β[i+1]
    end
    u
end

progonka(a,b,c,f)=progonka!(similar(f),a,b,c,f)

function tprogonka()
    N=1000
    a=-rand(N-1)
    c=-rand(N-1)
    b=2.0.+rand(N)
    f=rand(N)

    A=Tridiagonal(a,b,c)
    utri=A\f
    upro=progonka(a,b,c,f)
    @assert utri≈upro
    @btime utri=$A\$f
    @btime upro=progonka($a,$b,$c,$f)
    nothing
end


text:
module FSimROS

using PyCall

using UnPack

using FSimBase, FSimZoo
using StaticArrays, ReferenceFrameRotations

include("convert.jl")

export state_to_msg, msg_to_state

end


text:
using PkgSRA, Plots, LinearAlgebra, Statistics, Turing, Distributions
using AxisArrays, DataStructures
using BSON: @load
pyplot()

#####
##### Load variables
#####
# Load true model
include(EXAMPLE_FOLDERNAME*"example_lorenz.jl")

include("paper_settings.jl")
this_dat_name = DAT_FOLDERNAME*"TMP_dat_flowchart_inkscape_"

# Intermediate data
fname = this_dat_name*"intermediate.bson";
@load fname chain chain_sub
# SINDy variables 1: before control
fname = this_dat_name*"naive_vars_sindy.bson";
@load fname unctr_nz_terms unctr_nz_names
# SINDY variables 2: after control
fname = this_dat_name*"ctr_vars_sindy.bson";
@load fname sub_nz_terms sub_nz_names

#####
##### Plot
#####

a = sample(chain[:noise], 1000)
b = sample(chain_sub[:noise], 1000)

histogram(Array.([a,b]), bar_width=0.5)

histogram(a, bar_width=0.5)
    histogram!(b)

d1 = chain[:noise].value.data[:,1,1]
plot_noise = histogram(d1, legend=false)
d2 = chain_sub[:noise].value.data[:,1,1]
width = plot_noise.series_list[1].plotattributes[:bar_width]
histogram!(d2, legend=false, bar_width=width[1], nbins=1)

plot_noise.series_list[1].plotattributes[:bar_width]

plot_var = "all_coef[1]"

# d1 = chain[var].value.data[:,1,1]
plot_noise = density(chain[plot_var], legend=false)
density!(chain_sub[plot_var], legend=false)

mixeddensity(chain_sub)


text:
@testset "parallel_PARSDMM" begin

# if nworkers()==1
#   addprocs(3)
# end

#test parallel PARSDMM (test is for 2 workers)
    options=PARSDMM_options()
    default_PARSDMM_options(options,Float64)
    options.parallel = true
    options.evol_rel_tol = 10*eps()
    options.maxit=5000

    x=randn(100,201)

    comp_grid=compgrid((1.0, 1.0),(100, 201))
    x         = vec(x)
    m         = deepcopy(x)

    constraint=Dict()

    #total variation
    (TV_OP, AtA_diag, dense, TD_n)=get_TD_operator(comp_grid,"TV",options.FL)
    constraint["use_TD_l1_1"]      = true
    constraint["TD_l1_operator_1"] = "TV"
    constraint["TD_l1_sigma_1"]    = 0.5*norm(TV_OP*x,1)

    (P_sub,TD_OP,TD_Prop) = setup_constraints(constraint,comp_grid,options.FL);
    (TD_OP,AtA,l,y) = PARSDMM_precompute_distribute(TD_OP,TD_Prop,comp_grid,options)

    (x1,log_PARSDMM) = PARSDMM(m,AtA,TD_OP,TD_Prop,P_sub,comp_grid,options);
    result=Vector{typeof(x[1])}(length(x1))
    for i=1:length(TD_OP)-1
      copy!(result,x1)
      @test norm(P_sub[i](TD_OP[i]*result)-(TD_OP[i]*result))/norm((TD_OP[i]*result)) <= options.feas_tol
    end

#test parallel PARSDMM without many explicit BLAS calls (test is for 2 workers)
    default_PARSDMM_options(options,Float64)
    options.parallel    = true
    options.Blas_active = false

    (P_sub,TD_OP,TD_Prop) = setup_constraints(constraint,comp_grid,options.FL);
    (TD_OP,AtA,l,y) = PARSDMM_precompute_distribute(TD_OP,TD_Prop,comp_grid,options)

    (x2,log_PARSDMM) = PARSDMM(m,AtA,TD_OP,TD_Prop,P_sub,comp_grid,options);
    result=Vector{typeof(x[1])}(length(x2))
    for i=1:length(TD_OP)-1
      copy!(result,x2)
      @test norm(P_sub[i](TD_OP[i]*result)-(TD_OP[i]*result))/norm((TD_OP[i]*result)) <= options.feas_tol
    end

#test if with and ithout expicit Blas calls results are the same
@test isapprox(x1,x2,rtol=1e-12)

#run serial PARSDMM and compare results
    default_PARSDMM_options(options,Float64)
    options.parallel    = false

    (P_sub,TD_OP,TD_Prop) = setup_constraints(constraint,comp_grid,options.FL);
    (TD_OP,AtA,l,y) = PARSDMM_precompute_distribute(TD_OP,TD_Prop,comp_grid,options)

    (x3,log_PARSDMM) = PARSDMM(m,AtA,TD_OP,TD_Prop,P_sub,comp_grid,options);
    result=Vector{typeof(x[1])}(length(x3))
    for i=1:length(TD_OP)-1
      copy!(result,x3)
      @test norm(P_sub[i](TD_OP[i]*result)-(TD_OP[i]*result))/norm((TD_OP[i]*result)) <= options.feas_tol
    end

@test isapprox(x1,x3,rtol=1e-12)

#test parallel PARDMM with a JOLI operator in a projector, but not in TD_OP
default_PARSDMM_options(options,Float64)
options.parallel    = false
options.evol_rel_tol = 10*eps()
constraint=Dict()

#DFT l1 constraints
(DFT, AtA_diag, dense, TD_n)=get_TD_operator(comp_grid,"DFT",options.FL)
constraint["use_TD_l1_1"]      = true
constraint["TD_l1_operator_1"] = "DFT"
constraint["TD_l1_sigma_1"]    = 0.5*norm(DFT*x,1)

(P_sub,TD_OP,TD_Prop) = setup_constraints(constraint,comp_grid,options.FL);
(TD_OP,AtA,l,y) = PARSDMM_precompute_distribute(TD_OP,TD_Prop,comp_grid,options)

(x1,log_PARSDMM) = PARSDMM(m,AtA,TD_OP,TD_Prop,P_sub,comp_grid,options);
result=Vector{typeof(x[1])}(length(x1))
for i=1:length(TD_OP)-1
  copy!(result,x1)
  @test norm(P_sub[i](TD_OP[i]*result)-(TD_OP[i]*result))/norm((TD_OP[i]*result)) <= options.feas_tol
end

#test parallel PARDMM with a JOLI operator in TD_OP
default_PARSDMM_options(options,Float64)
options.parallel    = false

constraint=Dict()

#DFT l1 constraints
(C, AtA_diag, dense, TD_n)=get_TD_operator(comp_grid,"curvelet",options.FL)
constraint["use_TD_l1_1"]      = true
constraint["TD_l1_operator_1"] = "curvelet"
constraint["TD_l1_sigma_1"]    = 0.5*norm(C*x,1)

(P_sub,TD_OP,TD_Prop) = setup_constraints(constraint,comp_grid,options.FL);
(TD_OP,AtA,l,y) = PARSDMM_precompute_distribute(TD_OP,TD_Prop,comp_grid,options)

(x1,log_PARSDMM) = PARSDMM(m,AtA,TD_OP,TD_Prop,P_sub,comp_grid,options);
result=Vector{typeof(x[1])}(length(x1))
for i=1:length(TD_OP)-1
  copy!(result,x1)
  @test norm(P_sub[i](TD_OP[i]*result)-(TD_OP[i]*result))/norm((TD_OP[i]*result)) <= options.feas_tol
end

end


text:
using Behavior
using Niancat
using Niancat.Http
import Niancat.Http: post
using Niancat.Games.NiancatGames
using Niancat.Gameface: GameNotification
using SQLite

column(t::Behavior.Gherkin.DataTable) = [row[1] for row in t]

@given("that we add no instances") do context
    # Nothing to do.
end

@given("that we add instances") do context
    service = context[:service]
    instancenames = column(context.datatable)

    for name in instancenames
        declareinstance!(service, name)
    end
end

@when("all instances are listed") do context
    service = context[:service]
    instancenames = listinstancenames(service)

    context[:instancenames] = instancenames
end

@then("the listed instances are") do context
    expectedinstancenames = sort(column(context.datatable))
    actualinstancenames = sort(context[:instancenames])

    @expect expectedinstancenames == actualinstancenames
end

@given("a new database file") do context
    context[:databasefile] = Base.Filesystem.tempname()
end

@when("a Niancat service is started") do context
    databasefile = context[:databasefile]
    sqlitedb = SQLite.DB(databasefile)
    service = NiancatService(sqlitedb)

    registergame!(service, "Niancat", "#sv-14#", (state, gameservice) -> NiancatGame(state, gameservice))
    loadgameinstances!(service)

    context[:service] = service
end

@then("the database has the default tables") do context
    databasefile = context[:databasefile]
    sqlitedb = SQLite.DB(databasefile)

    result = SQLite.tables(sqlitedb)
    actualtables = result[:name]

    expectedtables = column(context.datatable)

    for expectedtable in expectedtables
        @expect expectedtable in actualtables
    end
end

@when("an existing database file") do context
    databasefile = Base.Filesystem.tempname()
    context[:databasefile] = databasefile

    sqlitedb = SQLite.DB(databasefile)
    service = NiancatService(sqlitedb)

    registergame!(service, "Niancat", "#sv-14#", (state, gameservice) -> NiancatGame(state, gameservice))
    loadgameinstances!(service)

    newgame!(service, "defaultinstance", "Niancat")

    context[:service] = service
end

@given("that the team defaultteam updates the notification endpoint to {String}") do context, endpoint_url
    service = context[:service]
    teamname = "defaultteam"

    updateteamendpoint!(service, teamname, endpoint_url)
end

struct SomeFakeNotification <: GameNotification
    msg::String
end

@when("a notification is sent for the instance defaultinstance") do context
    service = context[:service]
    somegame = getgame(service.instances, "Niancat", "defaultinstance")

    notify!(somegame.gameservice, SomeFakeNotification("You are notified"))
end

@then("the notification is sent to {String}") do context, endpoint_url
    httpclient = context[:httpclient]

    notifications_uris = [u for (u, _body) in httpclient.posts]

    @expect endpoint_url in notifications_uris
end


text:
"""
    Size(s::Tuple{Vararg{Union{Int,StaticInt}})
    Size(A) -> Size(size(A))

Type that represents statically sized dimensions as `StaticInt`s.
"""
struct Size{S<:Tuple}
    size::S

    Size{S}(s::Tuple{Vararg{<:CanonicalInt}}) where {S} = new{S}(s::S)
    Size(s::Tuple{Vararg{<:CanonicalInt}}) = Size{typeof(S)}(s)
end

Base.ndims(::Size{S}) where {S} = known_length(S)
Base.ndims(::Type{<:Size{S}}) where {S} = known_length(S)
Base.size(s::Size{Tuple{Vararg{Int}}}) = getfield(s, :size)
Base.size(s::Size) = map(Int, s.size)
function Base.size(s::Size{S}, dim::CanonicalInt) where {S}
    if dim > known_length(S)
        return 1
    else
        return Int(getfield(s.size, Int(dim)))
    end
end

@inline Size(A) = Size(_size(A, Val(known_size(A))))
@generated function _size(A, ::Val{S}) where {S}
    t = Expr(:tuple)
    for i in 1:length(S)
        si = S[i]
        if si === missing
            push!(t.args, :(Base.size(A, $i)))
        else
            push!(t.args, :($(static(si))))
        end
    end
    Expr(:block, Expr(:meta, :inline), t)
end
Size(x, dim) = _Length(x, to_dims(x, dim))
@inline function _Length(x, dim::Union{Int,StaticInt})
    sz = known_size(x, dim)
    if sz === missing
        return Length(Base.size(x, dim))
    else
        return Length(static(sz))
    end
end
Base.:(==)(x::Size, y::Size) = getfield(x, :size) == getfield(y, :size)

## Length
"""
    Length(x::Union{Int,StaticInt})
    Length(A) = Length(length(A))

Type that represents statically sized dimensions as `StaticInt`s.
"""
const Length{L} = Size{Tuple{L}}
Length(x::CanonicalInt) = Size((x,))
@inline function Length(x)
    len = known_length(x)
    if len === missing
        return Length(length(x))
    else
        return Length(static(len))
    end
end

ArrayInterface.known_size(::Type{<:Size{S}}) where {S} = known(S)


text:
using BinaryBuilder

name = "IntelOpenMP"
version = v"2018.0.3"

sources = [
    ArchiveSource("https://anaconda.org/intel/openmp/2018.0.3/download/win-32/openmp-2018.0.3-intel_0.tar.bz2",
                  "86ed603332ed7b4004e8a474943468589b222ef16d0d9aaf3ebb4ceaf743a39d"; unpack_target="i686-w64-mingw32"),
    ArchiveSource("https://anaconda.org/intel/openmp/2018.0.3/download/win-64/openmp-2018.0.3-intel_0.tar.bz2",
                  "0aee3d9debb8b1c2bb9a202b780c2b2d2179e4cee9158f7d0ad46125cf6f3fa2"; unpack_target="x86_64-w64-mingw32"),
    ArchiveSource("https://anaconda.org/intel/openmp/2018.0.3/download/osx-64/openmp-2018.0.3-intel_0.tar.bz2",
                  "110b94d5ff3c4df66fc89030c30ad42378da02817b3962f14cb5c268f9d94dae"; unpack_target="x86_64-apple-darwin14"),
    ArchiveSource("https://anaconda.org/intel/openmp/2018.0.3/download/linux-32/openmp-2018.0.3-intel_0.tar.bz2",
                  "f06edc0c52337658fd4b780d0b5c704b0ffb1c156dced7f5038c1ebbda3d891b"; unpack_target="i686-linux-gnu"),
    ArchiveSource("https://anaconda.org/intel/openmp/2018.0.3/download/linux-64/openmp-2018.0.3-intel_0.tar.bz2",
                  "cae3ef59d900f12c723a3467e7122b559f0388c08c40c332da832131c024409b"; unpack_target="x86_64-linux-gnu"),
]

# Bash recipe for building across all platforms
script = raw"""
cd $WORKSPACE/srcdir
mkdir -p "${libdir}"
    if [[ ${target} == *mingw* ]]; then
    mv ${target}/Library/bin/* "${libdir}/."
else
    mv ${target}/lib/* "${libdir}/."
fi
install_license ${target}/info/*.txt
"""

# The products that we will ensure are always built
products = [
    LibraryProduct(["libiomp5", "libiomp5md"], :libiomp),
]

# Dependencies that must be installed before this package can be built
dependencies = Dependency[
]

non_reg_ARGS = filter(arg -> arg != "--register", ARGS)
include("../../fancy_toys.jl")
no_autofix_platforms = [Platform("x86_64", "macos")]
autofix_platforms = [Platform("i686", "windows"), Platform("x86_64", "windows"), Platform("x86_64", "linux"), Platform("i686", "linux")]
if any(should_build_platform.(triplet.(no_autofix_platforms)))
    # Need to disable autofix: setting the soname on libiomp breaks it:
    # https://github.com/JuliaMath/FFTW.jl/pull/178#issuecomment-761904389
    build_tarballs(non_reg_ARGS, name, version, sources, script, no_autofix_platforms, products, dependencies; autofix = false)
end
if any(should_build_platform.(triplet.(autofix_platforms)))
    # Let's try to run autofix on the other platforms
    build_tarballs(ARGS, name, version, sources, script, autofix_platforms, products, dependencies)
end

max_stars_repo_name: sharanry/Yggdrasil

max_issues_repo_name: sharanry/Yggdrasil

max_forks_repo_name: sharanry/Yggdrasil


text:
using  Thebes

@svg begin
perspective(1200)
eyepoint(500, 500, 150)
k = 20
w, h = 20, 20
for x in 1:8
    for y in 1:8
        iseven(x + y) ? sethue("grey90") : sethue("grey10")

        z = 0
        plist = [
            Point3D(k * x,     k * y,  z),
            Point3D(k * x + w, k * y,  z),
            Point3D(k * x + w, k * y + h,  z),
            Point3D(k * x, k * y + h,  z)
            ]

        pts = pin(plist, gfunction = (p3, p2) -> begin
            d = distance(p3[1], Point3D(0, 0, 0))

            poly(p2, close=true, :fillpreserve)
            sethue("black")
            strokepath()
            end)

        #text("x$x/y$y", polycentroid(pts))
        end
    end
end 500 500 "/tmp/t.svg"


text:
# Copyright (c) 2013: Cbc.jl contributors
#
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.

# Automatically generated using Clang.jl

const Clp_Simplex = Cvoid
const clp_callback = Ptr{Cvoid}
const Sbb_Model = Cvoid
const Cbc_Model = Cvoid
const sbb_callback = Ptr{Cvoid}
const cbc_callback = Ptr{Cvoid}
const cbc_cut_callback = Ptr{Cvoid}
const CoinBigIndex = Cint


text:
@testset "double pendulum" begin
    xs = DoublePendulum.get_data(i=0, n=100)

    @test size(xs) == (6, 100)
end


text:
# directory of CBLIB files
cblib_dir = joinpath(ENV["HOME"], "cblib/cblib.zib.de/download/all")
if !isdir(cblib_dir)
    @warn("CBLIB download folder not found")
    cblib_dir = joinpath(@__DIR__, "cblib_data")
    cblib_diverse = String[]
else
    cblib_diverse = [
        "expdesign_D_8_4", # psd, exp
        "port_12_9_3_a_1", # psd, soc, exp
        "tls4", # soc
        "ck_n25_m10_o1_1", # rsoc
        "rsyn0805h", # exp
        "2x3_3bars", # psd
        "HMCR-n20-m400", # power
        "classical_20_0", # soc, orthant
        "achtziger_stolpe06-6.1flowc", # rsoc, orthant
        "LogExpCR-n100-m400", # exp, orthant
        ]
end

relaxed_tols = (default_tol_relax = 1000,)
insts = OrderedDict()
insts["minimal"] = [(("expdesign_D_8_4",), nothing, relaxed_tols)]
insts["fast"] = [((inst,), nothing, relaxed_tols) for inst in cblib_diverse]
insts["various"] = insts["fast"]
return (CBLIBJuMP, insts)