text:
# 04 dimension reduction

# using the libraries
using UMAP, XLSX, VegaDatasets, DataFrames, MultivariateStats, RDatasets, StatsBase, Statistics, LinearAlgebra, Plots, ScikitLearn, MLBase, Distances

# import the data
C = DataFrame(VegaDatasets.dataset("cars"));
describe(C);

# clean the data
dropmissing!(C);
M = Matrix{Float64}(C[!, 2:7]);
n = names(C)[2:end];

# For MLBase and label map
# USA -> 1
# Europe -> 2 etc...
car_origin = C[!, :Origin];
unique(car_origin);
carmap = labelmap(car_origin);
uniqueids = labelencode(carmap, car_origin)

# PCA approximate the matrix
# Center and standardize the data
data = M;
data = (data .- mean(data, dims=1)) ./ std(data, dims=1);

# fit the data
p = fit(PCA, data', maxoutdim=2)

# projection
P = projection(p);
P' * (data[1, :] - mean(p))

#
Yte = P' * data'
Yte = MultivariateStats.transform(p, data')

# reconstruct the matrix
Xr = reconstruct(p, Yte);
data' - Xr;
@show norm(data' - Xr)
# the approximation gets better when more maxoutdims are used.

# plotting
scatter(Yte[1,:],Yte[2,:])

scatter(Yte[1,car_origin.=="USA"],Yte[2,car_origin.=="USA"],color=1,label="USA")
scatter!(Yte[1,car_origin.=="Japan"],Yte[2,car_origin.=="Japan"],color=2,label="Japan")
scatter!(Yte[1,car_origin.=="Europe"],Yte[2,car_origin.=="Europe"],color=3,label="Europe")
xlabel!("pca component1")
ylabel!("pca component2")

# three dim maxxout
p = fit(PCA,data',maxoutdim=3)
Yte = MultivariateStats.transform(p, data')
scatter3d(Yte[1,:],Yte[2,:],Yte[3,:],color=uniqueids,legend=false)

# tsne
# @sk_import manifold : TSNE
tfn = TSNE(n_components=3 ,perplexity=20.0,early_exaggeration=50)
Y2 = tfn.fit_transform(data);
scatter(Y2[:,1],Y2[:,2],Y2[:,3],color=uniqueids,legend=false,size=(400,300),markersize=3)

# umap
L = cor(data,data,dims=2)
@time embedding = umap(L, )

scatter(embedding[1,:],embedding[2,:],color=uniqueids)

# different distance
@time L2 = pairwise(Euclidean(), data, data,dims=1)
embedding = umap(-L, 2)
scatter(embedding[1,:],embedding[2,:],color=uniqueids)

max_stars_repo_path: 04. Dimensionality Reduction.jl

max_issues_repo_path: 04. Dimensionality Reduction.jl

max_forks_repo_path: 04. Dimensionality Reduction.jl


text:
#------------------------------------------------------------#
# Build the objective function for QuantumCircuitModel here  #
#------------------------------------------------------------#

function objective_minimize_total_depth(qcm::QuantumCircuitModel)

    n_r          = size(qcm.data["gates_real"])[1]
    n_c          = size(qcm.data["gates_real"])[2]
    depth        = qcm.data["maximum_depth"]
    identity_idx = qcm.data["identity_idx"]
    num_gates    = size(qcm.data["gates_real"])[3]

    decomposition_type = qcm.data["decomposition_type"]

    if !isempty(identity_idx)

        if decomposition_type == "exact"
            JuMP.@objective(qcm.model, Min, sum(qcm.variables[:z_onoff_var][n,d] for n = 1:num_gates, d=1:depth if !(n in identity_idx)))

        elseif decomposition_type == "approximate"
            JuMP.@objective(qcm.model, Min, sum(qcm.variables[:z_onoff_var][n,d] for n = 1:num_gates, d=1:depth if !(n in identity_idx)) + qcm.options.objective_slack_penalty * sum(qcm.variables[:slack_var][i,j]^2 for i=1:n_r, j=1:n_c))

        end

    else

        Memento.warn(_LOGGER, "Switching to a feasibility problem since Identity gate is not part of input elementary gates")
        QCO.objective_feasibility(qcm)

    end

    return
end

function objective_feasibility(qcm::QuantumCircuitModel)
    n_r     = size(qcm.data["gates_real"])[1]
    n_c     = size(qcm.data["gates_real"])[2]

    decomposition_type = qcm.data["decomposition_type"]

    if decomposition_type == "exact"
        # Feasibility objective

    elseif decomposition_type == "approximate"
        JuMP.@objective(qcm.model, Min, sum(qcm.variables[:slack_var][i,j]^2 for i=1:n_r, j=1:n_c))

    end

    return
end

function objective_minimize_cnot_gates(qcm::QuantumCircuitModel)

    n_r      = size(qcm.data["gates_real"])[1]
    n_c      = size(qcm.data["gates_real"])[2]
    depth    = qcm.data["maximum_depth"]
    cnot_idx = qcm.data["cnot_idx"]

    decomposition_type = qcm.data["decomposition_type"]

    if !isempty(qcm.data["cnot_idx"])

        if decomposition_type == "exact"
            JuMP.@objective(qcm.model, Min, sum(qcm.variables[:z_onoff_var][n,d] for n in cnot_idx, d=1:depth))

        elseif decomposition_type == "approximate"
            JuMP.@objective(qcm.model, Min, sum(qcm.variables[:z_onoff_var][n,d] for n in cnot_idx, d=1:depth) + (qcm.options.objective_slack_penalty * sum(qcm.variables[:slack_var][i,j]^2 for i=1:n_r, j=1:n_c)))

        end

    elseif isempty(qcm.data["cnot_idx"]) && !isempty(qcm.data["identity_idx"])

        Memento.warn(_LOGGER, "Switching the objective to minimize the total depth since CNOT gate is not part of the input elementary gates")
        QCO.objective_minimize_total_depth(qcm)

    else

        Memento.warn(_LOGGER, "Switching to a feasibility problem since CNOT and Identity gates are not part of input elementary gates")
        QCO.objective_feasibility(qcm)

    end

    return
end

ext: jl


text:
"""
    MultiLens([castout,] lenses::Tuple)
    MultiLens([castout,] lenses::NamedTuple)

# Examples
```jldoctest
julia> using Setfield, Kaleido

julia> ml = MultiLens((
           (@lens _.x),
           (@lens _.y.z),
       ))
〈◻.x, ◻.y.z〉

julia> get((x=1, y=(z=2,)), ml)
(1, 2)

julia> set((x=1, y=(z=2,)), ml, ("x", "y.z"))
(x = "x", y = (z = "y.z",))

julia> ml = MultiLens((
           a = (@lens _.x),
           b = (@lens _.y.z),
       ))
〈◻.x, ◻.y.z〉

julia> get((x=1, y=(z=2,)), ml)
(a = 1, b = 2)

julia> set((x=1, y=(z=2,)), ml, (a=:x, b="y.z"))
(x = :x, y = (z = "y.z",))

julia> set((x=1, y=(z=2,)), ml, (b="y.z", a=:x))
(x = :x, y = (z = "y.z",))

julia> using StaticArrays

julia> ml = MultiLens(
           SVector,
           (
               (@lens _.x),
               (@lens _.y.z),
           )
       )
〈◻.x, ◻.y.z〉

julia> @assert get((x=1, y=(z=2,)), ml) === SVector(1, 2)
```
"""
MultiLens

const Lenses{N} = NTuple{N, Lens}
const NamedLenses{N, names} = NamedTuple{names, <:Lenses{N}}
const AnyLenses{N} = Union{Lenses{N}, NamedLenses{N}}

struct MultiLens{N, TL <: AnyLenses{N}, TO} <: KaleidoLens
    castout::TO
    lenses::TL

    global _MultiLens(castout::TO, lenses::TL) where {N, TL <: AnyLenses{N}, TO} =
        new{N, TL, TO}(castout, lenses)
end

MultiLens(castout, lenses) =
    _MultiLens(prefer_singleton_callable(castout), lenses)

MultiLens(lenses::Lenses) = MultiLens(identity, lenses) :: MultiLensTuples
MultiLens(lenses::NamedTuple{names, <:Lenses}) where names =
    MultiLens(NamedTuple{names}, lenses) :: MultiLensNamedTuples

const MultiLensTuples{N} = MultiLens{N, <:Lenses{N}, typeof(identity)}
const MultiLensNamedTuples{N, names} = MultiLens{
    N,
    <:NamedLenses{N, names},
    SingletonCallable{NamedTuple{names}},
}

_getall(obj, lenses) = map(l -> get(obj, l), lenses)

Setfield.get(obj, ml::MultiLens) = ml.castout(_getall(obj, ml.lenses))

Setfield.set(obj, ml::MultiLens{N, <:Lenses{N}}, val) where N =
    _foldl(_enumerate(ml.lenses), obj) do obj, (i, l)
        set(obj, l, val[i])
    end

Setfield.set(obj, ml::MultiLens{N, <:NamedLenses{N, names}}, val) where {N, names} =
    set(
        obj,
        MultiLens(Tuple(ml.lenses)),
        map(n -> val[n], names) :: Tuple,
    )

# Print like `MultiLens((l1, l2))` and `MultiLens((a=l1, b=l2))`
Base.show(io::IO, lens::Union{MultiLensTuples, MultiLensNamedTuples}) =
    print_apply(io, MultiLens, (lens.lenses,))


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

mutable struct IoK8sApiCoreV1NodeSelectorRequirement <: SwaggerModel
    key::Any # spec type: Union{ Nothing, String } # spec name: key
    operator::Any # spec type: Union{ Nothing, String } # spec name: operator
    values::Any # spec type: Union{ Nothing, Vector{String} } # spec name: values

    function IoK8sApiCoreV1NodeSelectorRequirement(;key=nothing, operator=nothing, values=nothing)
        o = new()
        validate_property(IoK8sApiCoreV1NodeSelectorRequirement, Symbol("key"), key)
        setfield!(o, Symbol("key"), key)
        validate_property(IoK8sApiCoreV1NodeSelectorRequirement, Symbol("operator"), operator)
        setfield!(o, Symbol("operator"), operator)
        validate_property(IoK8sApiCoreV1NodeSelectorRequirement, Symbol("values"), values)
        setfield!(o, Symbol("values"), values)
        o
    end
end # type IoK8sApiCoreV1NodeSelectorRequirement

const _property_map_IoK8sApiCoreV1NodeSelectorRequirement = Dict{Symbol,Symbol}(Symbol("key")=>Symbol("key"), Symbol("operator")=>Symbol("operator"), Symbol("values")=>Symbol("values"))
const _property_types_IoK8sApiCoreV1NodeSelectorRequirement = Dict{Symbol,String}(Symbol("key")=>"String", Symbol("operator")=>"String", Symbol("values")=>"Vector{String}")
Base.propertynames(::Type{ IoK8sApiCoreV1NodeSelectorRequirement }) = collect(keys(_property_map_IoK8sApiCoreV1NodeSelectorRequirement))
Swagger.property_type(::Type{ IoK8sApiCoreV1NodeSelectorRequirement }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_IoK8sApiCoreV1NodeSelectorRequirement[name]))}
Swagger.field_name(::Type{ IoK8sApiCoreV1NodeSelectorRequirement }, property_name::Symbol) =  _property_map_IoK8sApiCoreV1NodeSelectorRequirement[property_name]

function check_required(o::IoK8sApiCoreV1NodeSelectorRequirement)
    (getproperty(o, Symbol("key")) === nothing) && (return false)
    (getproperty(o, Symbol("operator")) === nothing) && (return false)
    true
end

function validate_property(::Type{ IoK8sApiCoreV1NodeSelectorRequirement }, name::Symbol, val)
end


text:
"""
    FEMMDeforLinearIMModule

Module for operations on interiors of domains to construct system matrices and
system vectors for linear deformation models: incompatible-mode formulation.
"""
module FEMMDeforLinearIMModule

__precompile__(true)

using FinEtools.FTypesModule: FInt, FFlt, FCplxFlt, FFltVec, FIntVec, FFltMat, FIntMat, FMat, FVec, FDataDict
import FinEtools.FENodeSetModule: FENodeSet
import FinEtools.FESetModule: AbstractFESet, FESetH8, FESetT10, manifdim, nodesperelem, gradN!, bfun, bfundpar
import FinEtools.IntegDomainModule: IntegDomain, integrationdata, Jacobianvolume
import FinEtools.IntegRuleModule: GaussRule
import FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: AbstractFEMMDeforLinear
import FinEtoolsDeforLinear.DeforModelRedModule: AbstractDeforModelRed, DeforModelRed3D
import FinEtoolsDeforLinear.MatDeforLinearElasticModule: AbstractMatDeforLinearElastic, tangentmoduli!, update!, thermalstrain!
import FinEtoolsDeforLinear.MatDeforElastIsoModule: MatDeforElastIso
import FinEtools.FieldModule: ndofs, gatherdofnums!, gatherfixedvalues_asvec!, gathervalues_asvec!, gathervalues_asmat!
import FinEtools.NodalFieldModule: NodalField
import FinEtools.CSysModule: CSys, updatecsmat!
import FinEtoolsDeforLinear.DeforModelRedModule: nstressstrain, nthermstrain, Blmat!, divmat, vgradmat
import FinEtools.AssemblyModule: AbstractSysvecAssembler, AbstractSysmatAssembler, SysmatAssemblerSparseSymm, startassembly!, assemble!, makematrix!, makevector!, SysvecAssembler
using FinEtools.MatrixUtilityModule: add_btdb_ut_only!, complete_lt!, loc!, jac!, locjac!
import FinEtoolsDeforLinear.FEMMDeforLinearBaseModule: stiffness, nzebcloadsstiffness, mass, thermalstrainloads, inspectintegpoints
import FinEtools.FEMMBaseModule: associategeometry!
import FinEtoolsDeforLinear.MatDeforModule: rotstressvec!
import LinearAlgebra: mul!, Transpose, UpperTriangular
using LinearAlgebra: Symmetric, cholesky, eigen
At_mul_B!(C, A, B) = mul!(C, Transpose(A), B)
A_mul_B!(C, A, B) = mul!(C, A, B)
import LinearAlgebra: norm, qr, diag, dot, cond
import Statistics: mean

"""
    FEMMDeforLinearIMH8{MR<:AbstractDeforModelRed, S<:FESetH8, F<:Function, M<:AbstractMatDeforLinearElastic}

Type for mean-strain linear deformation FEMM based on eight-node hexahedral elements.
"""
mutable struct FEMMDeforLinearIMH8{MR<:AbstractDeforModelRed, S<:FESetH8, F<:Function, M<:AbstractMatDeforLinearElastic}  <: AbstractFEMMDeforLinear
    mr::Type{MR}
    integdomain::IntegDomain{S, F} # geometry data
    mcsys::CSys # updater of the material orientation matrix
    material::M # material object
    nmodes::Int64
end

function FEMMDeforLinearIMH8(mr::Type{MR}, integdomain::IntegDomain{S, F}, mcsys::CSys, material::M) where {MR<:AbstractDeforModelRed,  S<:FESetH8, F<:Function, M<:AbstractMatDeforLinearElastic}
    @assert mr == material.mr "Model reduction is mismatched"
    @assert (mr == DeforModelRed3D) "3D model required"
    return FEMMDeforLinearIMH8(mr, integdomain, mcsys, material, 12)
end

function FEMMDeforLinearIMH8(mr::Type{MR}, integdomain::IntegDomain{S, F}, material::M) where {MR<:AbstractDeforModelRed,  S<:FESetH8, F<:Function, M<:AbstractMatDeforLinearElastic}
    @assert mr == material.mr "Model reduction is mismatched"
    @assert (mr == DeforModelRed3D) "3D model required"
    return FEMMDeforLinearIMH8(mr, integdomain, CSys(manifdim(integdomain.fes)), material, 12)
end

function FEMMDeforLinearIMH8(mr::Type{MR}, integdomain::IntegDomain{S, F}, material::M, nmodes::Int64) where {MR<:AbstractDeforModelRed,  S<:FESetH8, F<:Function, M<:AbstractMatDeforLinearElastic}
    @assert mr == material.mr "Model reduction is mismatched"
    @assert (mr == DeforModelRed3D) "3D model required"
    return FEMMDeforLinearIMH8(mr, integdomain, CSys(manifdim(integdomain.fes)), material, nmodes)
end

function  centroidintegrationdata(self)
	integration_rule = GaussRule(3, 1)
    pc::FFltMat = integration_rule.param_coords;
    w::FFltMat  =  integration_rule.weights ;
    npts::FInt = integration_rule.npts;
    # Precompute basis f. values + basis f. gradients wrt parametric coor
    Ns = FFltMat[];
    gradNparams = FFltMat[];
    for j=1:npts
        push!(Ns, bfun(self.fes,vec(pc[j,:])));
        push!(gradNparams, bfundpar(self.fes,vec(pc[j,:])));
    end
    @assert npts == 1
    return npts, reshape(Ns, 1,npts), reshape(gradNparams, 1,npts), w, pc
end

function imintegrationdata(nmodes, integration_rule)
    pc::FFltMat = integration_rule.param_coords;
    w::FFltMat  =  integration_rule.weights ;
    npts::FInt = integration_rule.npts;
    bfun(nmodes, pc) = begin
        if nmodes == 12 # Simo basis functions
        	N = [0.5 * (pc[1]^2 - 1);
        		 0.5 * (pc[2]^2 - 1);
        		 0.5 * (pc[3]^2 - 1);
        		 pc[1] * pc[2] * pc[3]]
        else # Wilson basis functions
        	N = [0.5 * (pc[1]^2 - 1);
        		 0.5 * (pc[2]^2 - 1);
        		 0.5 * (pc[3]^2 - 1)]
        end
        return reshape(N, length(N), 1)
    end
    bfundpar(nmodes, pc) = begin
        if nmodes == 12 # Simo basis functions
        	gradN = [pc[1] 0 0;
	        		 0 pc[2] 0;
	        		 0 0 pc[3];
	        		 (pc[2] * pc[3]) (pc[1] * pc[3]) (pc[1] * pc[2])]
        else # Wilson basis functions
        	gradN = [pc[1] 0 0;
	        		 0 pc[2] 0;
	        		 0 0 pc[3];]
        end
        return gradN
    end
    # Precompute basis f. values + basis f. gradients wrt parametric coor
    Ns = FFltMat[];
    gradNparams = FFltMat[];
    for j=1:npts
        push!(Ns, bfun(nmodes, vec(pc[j,:])));
        push!(gradNparams, bfundpar(nmodes, vec(pc[j,:])));
    end
    return reshape(Ns, 1, npts), reshape(gradNparams, 1, npts)
end

function imBlmat!(mr, imB, imNs, imgradN, loc0, csmat, nmodes)
	Blmat!(mr, imB, imNs, imgradN, loc0, csmat);
	if nmodes == 12
		imB[1:3, 10] .= imgradN[4, 1]
		imB[1:3, 11] .= imgradN[4, 2]
		imB[1:3, 12] .= imgradN[4, 3]
		imB[4:6, 10:12] .= 0.0
	end
end

function _buffers2(self, geom::NodalField, u::NodalField)
	fes = self.integdomain.fes
    ndn = ndofs(u); # number of degrees of freedom per node
    nne = nodesperelem(fes); # number of nodes for element
    sdim = ndofs(geom);            # number of space dimensions
    mdim = manifdim(fes); # manifold dimension of the element
    nstrs = nstressstrain(self.mr);  # number of stresses
    if self.nmodes == 12
    	nimne = 4
    else
    	nimne = 3
    end
    elmatdim = ndn*(nne + nimne); # dimension of the element matrix
    elmatcdim = ndn*nne;  # dimension of the condensed element matrix
    # Prepare buffers
    ecoords = fill(zero(FFlt), nne, ndofs(geom)); # array of Element coordinates
    elmat = fill(zero(FFlt), elmatdim, elmatdim);      # element matrix -- buffer
    elmatc = fill(zero(FFlt), elmatcdim, elmatcdim);      # element matrix -- buffer
    dofnums = zeros(FInt, 1, elmatcdim); # degree of freedom array -- buffer
    loc = fill(zero(FFlt), 1, sdim); # quadrature point location -- buffer
    J = fill(zero(FFlt), sdim, mdim); # Jacobian matrix -- buffer
    csmatTJ = fill(zero(FFlt), mdim, mdim); # intermediate result -- buffer
    loc0 = fill(zero(FFlt), 1, sdim); # quadrature point location -- buffer
    J0 = fill(zero(FFlt), sdim, mdim); # Jacobian matrix -- buffer
    csmatTJ0 = fill(zero(FFlt), mdim, mdim); # intermediate result -- buffer
    gradN = fill(zero(FFlt), nne, mdim); # intermediate result -- buffer
    gradN0 = fill(zero(FFlt), nne, mdim); # intermediate result -- buffer
    imgradN = fill(zero(FFlt), nimne, mdim); # intermediate result -- buffer
    D = fill(zero(FFlt), nstrs, nstrs); # material stiffness matrix -- buffer
    B = fill(zero(FFlt), nstrs, elmatdim); # strain-displacement matrix -- buffer
    DB = fill(zero(FFlt), nstrs, elmatdim); # strain-displacement matrix -- buffer
    Bc = fill(zero(FFlt), nstrs, elmatcdim); # strain-displacement matrix -- buffer
    imB = fill(zero(FFlt), nstrs, elmatdim - elmatcdim); # strain-displacement matrix -- buffer
    return ecoords, dofnums, loc, J, csmatTJ, loc0, J0, csmatTJ0, gradN, gradN0, imgradN, D, B, DB, Bc, imB, elmatc, elmat
end

"""
    associategeometry!(self::FEMMAbstractBase,  geom::NodalField{FFlt})

Associate geometry field with the FEMM.

Compute the  correction factors to account for  the shape of the  elements.
"""
function associategeometry!(self::F,  geom::NodalField{FFlt}) where {F<:FEMMDeforLinearIMH8}
    # Nothing needs to be done
    return self
end

"""
stiffness(self::AbstractFEMMDeforLinearIM, assembler::A,
      geom::NodalField{FFlt},
      u::NodalField{T}) where {A<:AbstractSysmatAssembler, T<:Number}

Compute and assemble  stiffness matrix.
"""
function stiffness(self::FEMMDeforLinearIMH8, assembler::A,
    geom::NodalField{FFlt},
    u::NodalField{T}) where {A<:AbstractSysmatAssembler, T<:Number}
    fes = self.integdomain.fes
    npts,  Ns,  gradNparams,  w,  pc = integrationdata(self.integdomain);
    npts0,  Ns0,  gradNparams0,  w0,  pc0 = centroidintegrationdata(self.integdomain);
    imNs, imgradNparams = imintegrationdata(self.nmodes, self.integdomain.integration_rule);
    ecoords, dofnums, loc, J, csmatTJ, loc0, J0, csmatTJ0, gradN, gradN0, imgradN, D, B, DB, Bc, imB, elmatc, elmat = _buffers2(self, geom, u)
    tangentmoduli!(self.material, D, 0.0, 0.0, loc, 0)
    startassembly!(assembler, size(elmatc, 1), size(elmatc, 2), count(fes), u.nfreedofs, u.nfreedofs);
    for i = 1:count(fes) # Loop over elements
        gathervalues_asmat!(geom, ecoords, fes.conn[i]);
        # NOTE: the coordinate system should be evaluated at a single point within the
        # element in order for the derivatives to be consistent at all quadrature points
        # Centroid data
        locjac!(loc0, J0, ecoords, Ns0[1], gradNparams0[1])
        updatecsmat!(self.mcsys, loc0, J0, fes.label[i]);
        Jac0 = Jacobianvolume(self.integdomain, J0, loc0, fes.conn[i], Ns0[1]);
        At_mul_B!(csmatTJ0, self.mcsys.csmat, J0); # local Jacobian matrix
        gradN!(fes, gradN0, gradNparams0[1], csmatTJ0);
        fill!(elmat,  0.0); # Initialize element matrix
        for j = 1:npts # Loop over quadrature points
        	locjac!(loc, J, ecoords, Ns[j], gradNparams[j])
        	Jac = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j]);
        	At_mul_B!(csmatTJ, self.mcsys.csmat, J); # local Jacobian matrix
        	gradN!(fes, gradN, gradNparams[j], csmatTJ);
        	Blmat!(self.mr, Bc, Ns[j], gradN, loc, self.mcsys.csmat);
        	B[:, 1:24] .= sqrt(Jac * w[j]) .* Bc
            gradN!(fes, imgradN, imgradNparams[j], csmatTJ0);
        	imBlmat!(self.mr, imB, imNs[j], imgradN, loc0, self.mcsys.csmat, self.nmodes);
        	B[:, 25:end] .= sqrt(Jac0 * w[j]) .* imB
        	add_btdb_ut_only!(elmat, B, 1.0, D, DB)
        end # Loop over quadrature points
        complete_lt!(elmat)
        # Static condensation
        elmatc .= elmat[1:24, 1:24] - elmat[1:24, 25:end] * (elmat[25:end, 25:end] \ elmat[25:end, 1:24])
        gatherdofnums!(u, dofnums, fes.conn[i]); # retrieve degrees of freedom
        assemble!(assembler, elmatc, dofnums, dofnums); # assemble symmetric matrix
    end # Loop over elements
    return makematrix!(assembler);
end

# """
# nzebcloadsstiffness(self::AbstractFEMMDeforLinear,  assembler::A,
#   geom::NodalField{FFlt},
#   u::NodalField{T}) where {A<:AbstractSysvecAssembler, T<:Number}

# Compute load vector for nonzero EBC for fixed displacement.
# """
# function nzebcloadsstiffness(self::FEMMDeforLinearIMH8,  assembler::A, geom::NodalField{FFlt}, u::NodalField{T}) where {A<:AbstractSysvecAssembler, T<:Number}
#     fes = self.integdomain.fes
#     npts,  Ns,  gradNparams,  w,  pc = integrationdata(self.integdomain);
#     ecoords, dofnums, loc, J, csmatTJ, AllgradN, MeangradN, Jac, D, Dstab, B, DB, Bbar, elmat, elvec, elvecfix = _buffers2(self, geom, u, npts)
#     realmat = self.material
#     stabmat = self.stabilization_material
#     tangentmoduli!(realmat, D, 0.0, 0.0, loc, 0)
#     tangentmoduli!(stabmat, Dstab, 0.0, 0.0, loc, 0)
#     startassembly!(assembler,  u.nfreedofs);
#     for i = 1:count(fes) # Loop over elements
#         gatherfixedvalues_asvec!(u, elvecfix, fes.conn[i]);# retrieve element displacement vector
#         if norm(elvecfix, Inf) != 0.0   # Is the load nonzero?
#             gathervalues_asmat!(geom, ecoords, fes.conn[i]);
#             # NOTE: the coordinate system should be evaluated at a single point within the
#             # element in order for the derivatives to be consistent at all quadrature points
#             loc = centroid!(self,  loc, ecoords)
#             updatecsmat!(self.mcsys, loc, J, fes.label[i]);
#             vol = 0.0; # volume of the element
#             fill!(MeangradN, 0.0) # mean basis function gradients
#             for j = 1:npts # Loop over quadrature points
#                 jac!(J, ecoords, gradNparams[j])
#                 Jac[j] = Jacobianvolume(self.integdomain, J, loc, fes.conn[i], Ns[j]);
#                 At_mul_B!(csmatTJ, self.mcsys.csmat, J); # local Jacobian matrix
#                 gradN!(fes, AllgradN[j], gradNparams[j], csmatTJ);
#                 dvol = Jac[j]*w[j]
#                 MeangradN .= MeangradN .+ AllgradN[j]*dvol
#                 vol = vol + dvol
#             end # Loop over quadrature points
#             MeangradN .= MeangradN/vol
#             Blmat!(self.mr, Bbar, Ns[1], MeangradN, loc, self.mcsys.csmat);
#             fill!(elmat,  0.0); # Initialize element matrix
#             add_btdb_ut_only!(elmat, Bbar, vol, D, DB)
#             add_btdb_ut_only!(elmat, Bbar, -self.phis[i]*vol, Dstab, DB)
#             for j = 1:npts # Loop over quadrature points
#                 Blmat!(self.mr, B, Ns[j], AllgradN[j], loc, self.mcsys.csmat);
#                 add_btdb_ut_only!(elmat, B, self.phis[i]*Jac[j]*w[j], Dstab, DB)
#             end # Loop over quadrature points
#             complete_lt!(elmat)
#             gatherdofnums!(u, dofnums, fes.conn[i]); # retrieve degrees of freedom
#             A_mul_B!(elvec, elmat, elvecfix)
#             assemble!(assembler,  -elvec,  dofnums); # assemble element load vector
#         end
#     end # Loop over elements
#     return makevector!(assembler);
# end

# function nzebcloadsstiffness(self::FEMMDeforLinearIMH8, geom::NodalField{FFlt}, u::NodalField{T}) where {T<:Number}
#     assembler = SysvecAssembler()
#     return  nzebcloadsstiffness(self, assembler, geom, u);
# end

end


text:
module TestElixirs

using LinearAlgebra
using Test
using Trixi

# Start with a clean environment: remove Trixi output directory if it exists
outdir = "out"
isdir(outdir) && rm(outdir, recursive=true)

# pathof(Trixi) returns /path/to/Trixi/src/Trixi.jl, dirname gives the parent directory
const EXAMPLES_DIR = joinpath(pathof(Trixi) |> dirname |> dirname, "examples")

@testset "Elixirs" begin
  @testset "Test linear structure (2D)" begin
    A, b = Trixi.compute_linear_structure(joinpath(EXAMPLES_DIR, "2d", "parameters.toml"),
                                          initial_refinement_level=2)
    λ = eigvals(Matrix(A))
    @test maximum(real, λ) < length(λ) * eps(real(eltype(λ)))

    A, b = Trixi.compute_linear_structure(joinpath(EXAMPLES_DIR, "2d", "parameters_hyp_diff_llf.toml"),
                                          Trixi.source_terms_harmonic,
                                          initial_refinement_level=2)
    λ = eigvals(Matrix(A))
    @test maximum(real, λ) < 10*length(λ) * eps(real(eltype(λ)))
  end

  @testset "Test Jacobian of DG (2D)" begin
    A, b = Trixi.compute_linear_structure(joinpath(EXAMPLES_DIR, "2d", "parameters.toml"),
                                          initial_refinement_level=2)
    J = Trixi.compute_jacobian_dg(joinpath(EXAMPLES_DIR, "2d", "parameters.toml"),
                                          initial_refinement_level=2)
    @test isapprox(Matrix(A), J)

    J = Trixi.compute_jacobian_dg(joinpath(EXAMPLES_DIR, "2d", "parameters_density_wave.toml"))
    λ = eigvals(J)
    @test maximum(real, λ) < 0.007
  end

  @testset "Test linear structure (3D)" begin
    A, b = Trixi.compute_linear_structure(joinpath(EXAMPLES_DIR, "3d", "parameters.toml"),
                                          polydeg=2, initial_refinement_level=1)
    λ = eigvals(Matrix(A))
    @test maximum(real, λ) < length(λ) * eps(real(eltype(λ)))

    A, b = Trixi.compute_linear_structure(joinpath(EXAMPLES_DIR, "3d", "parameters_hyp_diff_llf.toml"),
                                          Trixi.source_terms_harmonic,
                                          polydeg=2, initial_refinement_level=1)
    λ = eigvals(Matrix(A))
    @test maximum(real, λ) < 10*length(λ) * eps(real(eltype(λ)))
  end

  @testset "Test Jacobian of DG (3D)" begin
    A, b = Trixi.compute_linear_structure(joinpath(EXAMPLES_DIR, "3d", "parameters.toml"),
                                          polydeg=2, initial_refinement_level=1)
    J = Trixi.compute_jacobian_dg(joinpath(EXAMPLES_DIR, "3d", "parameters.toml"),
                                          polydeg=2, initial_refinement_level=1)
    @test isapprox(Matrix(A), J)
  end
end

# Clean up afterwards: delete Trixi output directory
@test_nowarn rm(outdir, recursive=true)

end #module


text:
# This file is a part of MGVI.jl, licensed under the MIT License (MIT).

"""
    abstract type AbstractJacobianFunc <: Function end

Abstract type of the jacobian calculators.

Represents the jacobian of the function. The instance can be called at the point `x`,
a LinearMap representing the jacobian is returned.
"""
abstract type AbstractJacobianFunc <: Function end

struct JacVecProdTag{F, T} end

function _dual_along(f::F, x::AbstractVector{T1}, δ::AbstractVector{T2}) where {F, T1, T2}
    T =  promote_type(T1, T2)
    T_Dual = JacVecProdTag{F, T}
    f(ForwardDiff.Dual{T_Dual}.(x, δ))
end

"""
    FullJacobianFunc(f)

Construct of the Jacobian with ForwardDiff.

When called at point `x`, the Jacobian matrix is fully instantiated
and stored explicitly in memory.

# Examples
```julia
# forward_model: x -> Distribution
jacobian_func = FullJacobianFunc(forward_model)
jacobian = jacobian_func(x)  # LinearMap
jacobian * δ  # act on vector
```
"""
struct FullJacobianFunc{F<:Function} <: AbstractJacobianFunc
    f::F
end

export FullJacobianFunc

function (jf::FullJacobianFunc)(x::AbstractVector{<:Real})
    f = jf.f
    y = f(x)
    U = promote_type(eltype(x), eltype(y))
    # ForwardDiff.jacobian is not type stable, so convert and fix type:
    jac = convert(Matrix{U}, ForwardDiff.jacobian(f, x))::Matrix{U}
    LinearMap{U}(jac, isposdef=false, issymmetric=false, ishermitian=false)
end

struct ForwardDiffJVP{F<:Function,T<:AbstractVector{<:Real}}
    f::F
    x::T
end

function (jvp::ForwardDiffJVP)(δ::AbstractVector{<:Real})
    ForwardDiff.partials.(_dual_along(jvp.f, jvp.x, δ), 1)
end

struct ForwardDiffVJP{F<:Function,T<:AbstractVector{<:Real}}
    f::F
    x::T
end

function (vjp::ForwardDiffVJP)(δ::AbstractVector{<:Real})
    f, x = vjp.f, vjp.x

    # Mathematically elegant, but not type stable and uses double differentiation:
    #jvp = ForwardDiffJVP(f, x)
    #g(t) = dot(δ, jvp(t))
    #ForwardDiff.gradient(g, zero(vjp.x))

    jvp = ForwardDiffJVP(f, x)
    U = promote_type(eltype(f(x)), eltype(x))
    result = similar(x, U)
    tmp = similar(x, U)
    for i in eachindex(x)
        tmp .= 0
        tmp[i] = 1
        result[i] = dot(δ, jvp(tmp))
    end
    result
end

struct ZygoteVJP{F<:Function,T,G<:Function}
    f::F
    x::T
    pullback::G
end

ZygoteVJP(f::Function, x) = ZygoteVJP(f, x, Zygote.pullback(f, x)[2])

@inline (vjp::ZygoteVJP)(δ) = first(vjp.pullback(δ))

"""
    FwdRevADJacobianFunc(f)

Construct of the Jacobian with ForwardDiff for direct action and Zygote.pullback for the adjoint

The Jacobian action is computed on the fly, no matrix is stored in memory at any time.

# Examples
```julia
# forward_model: x -> Distribution
jacobian_func = FwdRevADJacobianFunc(forward_model)
jacobian = jacobian_func(x)  # LinearMap
jacobian * δ  # act on vector as if it was a matrix
```
"""
struct FwdRevADJacobianFunc{F<:Function} <: AbstractJacobianFunc
    f::F
end

export FwdRevADJacobianFunc

function (jf::FwdRevADJacobianFunc)(x::AbstractVector{T}) where T
    f = jf.f
    y = f(x)
    jvp = ForwardDiffJVP(f, x)
    vjp = ZygoteVJP(f, x)
    LinearMap{T}(jvp, vjp, size(y, 1), size(x, 1), isposdef=false, issymmetric=false, ishermitian=false)
end

"""
    FwdDerJacobianFunc(f)

Construct of the Jacobian with ForwardDiff for the direct action, and twice applied
ForwardDiff for the adjoint action

Adjoint is implemented by introducing a placeholder parametric vector ``\\vec{t}``:

`` \\frac{d}{d\\vec{t}} \\vec{x} \\cdot (A \\vec{t}) = A^{T} \\vec{x} ``

This allows to implement both, the direct and adjoint actions, using
ForwardDiff, without instantiating full Jacobian at any point.
"""
struct FwdDerJacobianFunc{F<:Function} <: AbstractJacobianFunc
    f::F
end

export FwdDerJacobianFunc

function (jf::FwdDerJacobianFunc)(x::AbstractVector{T}) where T
    f = jf.f
    y = f(x)
    jvp = ForwardDiffJVP(f, x)
    vjp = ForwardDiffVJP(f, x)
    LinearMap{T}(jvp, vjp, size(y, 1), size(x, 1), isposdef=false, issymmetric=false, ishermitian=false)
end


text:
using StaticArrays
using GridInterpolations
using POMDPs
using AutomotiveDrivingModels
using AutomotivePOMDPs
using PedCar

mdp = PedCarMDP()

init_transition!(mdp)
init_collision_checker!(mdp)

rng = MersenneTwister(1)
N_SAMPLES = 10000
ns = n_states(mdp)
action_space = actions(mdp)
sampled_states = [ind2state(mdp, si) for si in rand(rng, 1:ns, N_SAMPLES)]

using ProfileView

Profile.clear()

@time for (i, s) in enumerate(sampled_states)
    @profile d = transition(mdp, s, rand(rng, action_space))
end

s = sampled_states[107]

d = transition(mdp, s, rand(rng, action_space))

mdp._car_transition_dict[(s.car, s.route, LonAccelDirection(-0.0, 1))]

LonAccelDirection(-0.0, 1) == LonAccelDirection(0.0, 1)


text:
using JuMP, EAGO

                     m = Model()

                     EAGO.register_eago_operators!(m)

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

                     @variable(m, -20.345339284625858 <= q <= 16.479136897808104)

                     add_NL_constraint(m, :((0.24719801624822457 + 0.29438950671798914*(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.7293079760660532*(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.8601808654748551*(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.9720568561360068*(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))))/(1 + exp(-(0.24719801624822457 + 0.29438950671798914*(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.7293079760660532*(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.8601808654748551*(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.9720568561360068*(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))))))) + (-0.49402133773229506 + 0.2465550492028581*(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.17626257051164496*(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.8688281780619751*(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.3904178182819744*(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))))/(1 + exp(-(-0.49402133773229506 + 0.2465550492028581*(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.17626257051164496*(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.8688281780619751*(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.3904178182819744*(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))))))) + (-0.6759660684871824 + 0.9311431633625067*(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.2015839225926066*(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.01676614484829253*(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.07861065087286123*(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))))/(1 + exp(-(-0.6759660684871824 + 0.9311431633625067*(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.2015839225926066*(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.01676614484829253*(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.07861065087286123*(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))))))) + (-0.08101830092609674 + 0.5708385401734484*(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.9629021826429458*(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.4780289946412233*(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.25224290978348307*(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))))/(1 + exp(-(-0.08101830092609674 + 0.5708385401734484*(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.7291821855933653 + 0.701331929085816*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.07780867500186073*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.19203457942980284*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.7065670431246684*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.9629021826429458*(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.05096633991424904 + 0.31501139336769945*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + -0.3152903616610754*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.8990116916055966*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.8373103942919853*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + 0.4780289946412233*(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.18255055897839467 + -0.7759686413687503*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.7813463540455929*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + 0.215367127826533*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + 0.9673448256726829*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))))))) + -0.25224290978348307*(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))/(1 + exp(-(0.5199334546165302 + 0.4081309459110076*(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2]))/(1 + exp(-(-0.7470183626892886 + -0.6899614176169906*$(x[1]) + -0.2208825424587011*$(x[2])))) + 0.6995024782698374*(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2]))/(1 + exp(-(-0.11062111710238876 + 0.5516588711870343*$(x[1]) + 0.9886940321128486*$(x[2])))) + -0.3131098472642604*(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2]))/(1 + exp(-(-0.28538228970678503 + -0.152956579710676*$(x[1]) + -0.25273256901725194*$(x[2])))) + -0.4135863095985335*(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2]))/(1 + exp(-(0.7652671472719401 + -0.8637339388616145*$(x[1]) + -0.2539724731598083*$(x[2])))))))))) - $q <= 0.0))

                     @objective(m, Min, q)

                     return m

max_stars_repo_name: PSORLab/RSActivationFunctions

max_issues_repo_name: PSORLab/RSActivationFunctions

max_forks_repo_name: PSORLab/RSActivationFunctions


text:
module ACWT
export
    acfilter,
    leftchild,
    rightchild
using Wavelets, LinearAlgebra

"""Computes ac coefficients of given filter"""
function autocorr(f::OrthoFilter)
    H = WT.qmf(f)
    l = length(H)
    result = zeros(l - 1)
    for k in 1:(l - 1)
        for i in 1:(l - k)
            @inbounds result[k] += H[i] * H[i + k]
        end
        result[k] *= 2
    end
    return result
end

"""Computes low ac filter"""
function pfilter(f::OrthoFilter)
    a = autocorr(f)
    c1 = 1 / sqrt(2)
    c2 = c1 / 2
    b = c2 * a
    return vcat(b[end:-1:1], c1, b)
end

"""Computes the high AC filter"""
function qfilter(f::OrthoFilter)
    a = autocorr(f)
    c1 = 1 / sqrt(2)
    c2 = c1 / 2
    b = -c2 * a
    return vcat(b[end:-1:1], c1, b)
end

function makeqmfpair(f::OrthoFilter)
    pmfilter, qmfilter = pfilter(f), qfilter(f)
    return pmfilter, qmfilter
end

function makereverseqmfpair(f::OrthoFilter)
    pmf, qmf = makeqmfpair(f)
    return reverse(pmf), reverse(qmf)
end

"""For acwpt array methods"""
leftchild(i::Integer) = i<<1;
rightchild(i::Integer) = i<<1+1;

end # End module

max_stars_repo_name: ShozenD/AutocorrelationShell

max_issues_repo_name: ShozenD/AutocorrelationShell

max_forks_repo_name: ShozenD/AutocorrelationShell


text:
# This file is part of InvertedFiles.jl

export BinaryInvertedFile, set_distance_evaluate

"""
    struct BinaryInvertedFile <: AbstractInvertedFile

Creates a binary weighted inverted index. An inverted index is an sparse matrix representation optimized for computing `k` nn elements (columns) under some distance.

# Properties:

- `dist`: Distance function to be applied, valid values are: `IntersectionDissimilarity()`, `DiceDistance()`, `JaccardDistance()`, and `CosineDistanceSet()
- `lists`: posting lists (non-zero values of the rows in the matrix)
- `sizes`: number of non-zero values per object (number of non-zero values per column)
- `locks`: Per row locks for multithreaded construction
"""
struct BinaryInvertedFile <: AbstractInvertedFile
    dist::Union{IntersectionDissimilarity,DiceDistance,JaccardDistance,CosineDistanceSet}
    lists::Vector{Vector{UInt32}}
    sizes::Vector{UInt32}
    locks::Vector{SpinLock}
end

"""
    set_distance_evaluate(dist::SemiMetric, intersection::Integer, size1::Integer, size2::Integer)

Computes the distance function `dist` on a [`BinaryInvertedFile`](@ref).
"""
set_distance_evaluate(::IntersectionDissimilarity, intersection::Integer, size1::Integer, size2::Integer)::Float32 = 1.0 - intersection / max(size1, size2)
set_distance_evaluate(::DiceDistance, intersection::Integer, size1::Integer, size2::Integer)::Float32 = 1.0 - (2intersection) / (size1 + size2)
set_distance_evaluate(::JaccardDistance, intersection::Integer, size1::Integer, size2::Integer)::Float32 = 1.0 - (intersection) / (size1 + size2 - intersection)
set_distance_evaluate(::CosineDistanceSet, intersection::Integer, size1::Integer, size2::Integer)::Float32 = 1.0 - (intersection) / (sqrt(size1) * sqrt(size2))

"""
    BinaryInvertedFile(vocsize::Integer, dist=JaccardDistance())

Creates an `BinaryInvertedFile` with the given vocabulary size and for the given distance function `dist`:

# Arguments:
- `vocsize`: the vocabulary size of the index
- `dist`: the distance function to be used in searches
"""
function BinaryInvertedFile(vocsize::Integer, dist=JaccardDistance())
    vocsize > 0 || throw(ArgumentError("voc must not be empty"))
    BinaryInvertedFile(dist, [UInt32[] for _ in 1:vocsize], UInt32[],  [SpinLock() for i in 1:vocsize])
end

function _internal_push!(idx::BinaryInvertedFile, tokenID, objID, _, sort)
    @inbounds L = idx.lists[tokenID]
    push!(L, objID)
    sort && sortlastpush!(L)
end


text:
using Cairo
using Compat, Colors
import Compat.String

@compat import Base.show

if VERSION >= v"0.5.0-dev+7720"
    using Base.Test
else
    using BaseTestNext
    const Test = BaseTestNext
end

# Image Surface
@testset "Image Surface  " begin

    surf = CairoImageSurface(100, 200, Cairo.FORMAT_ARGB32)
    @test width(surf) == 100
    @test height(surf) == 200
    ctx = CairoContext(surf)
    @test width(ctx) == 100
    @test height(ctx) == 200

    surf = CairoImageSurface(fill(RGB24(0), 10, 10))
    @test Cairo.format(surf) == RGB24
    io = IOBuffer()
    @compat show(io, MIME("image/png"), surf)

    seek(io,0)
    str_data = Vector{UInt8}(read(io))

    @test length(str_data) > 8 && str_data[1:8] == [0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a]
    surf = CairoImageSurface(fill(ARGB32(0), 10, 10))
    @test Cairo.format(surf) == ARGB32

end

@testset "Conversions    " begin

    include("shape_functions.jl")
    include("test_stream.jl")

    function test_pattern_get_surface()
        # test getting a surface from a surface pattern
        surf = CairoImageSurface(100, 200, Cairo.FORMAT_ARGB32)
        ctx = CairoContext(surf)
        Cairo.push_group(ctx)
        pattern = Cairo.pop_group(ctx)
        group_surf = Cairo.pattern_get_surface(pattern)
        @test group_surf.width == 100
        @test group_surf.height == 200

        # test that surfaces can't be gotten from non-surface patterns
        pattern = Cairo.pattern_create_linear(0, 0, 100, 200)
        @test_throws ErrorException Cairo.pattern_get_surface(pattern)
    end

    test_pattern_get_surface()

    # Test creating a CairoContext from a cairo_t pointer
    surf = CairoImageSurface(fill(ARGB32(0), 10, 10))
    ctx_ptr = ccall((:cairo_create, Cairo._jl_libcairo),Ptr{Void}, (Ptr{Void}, ), surf.ptr)
    ctx = CairoContext(ctx_ptr)
    ccall((:cairo_destroy,Cairo._jl_libcairo),Void, (Ptr{Void}, ), ctx_ptr)

    @test isa(ctx, CairoContext)
end

@testset "TexLexer       " begin
    include("tex.jl")
end

# Run all the samples -> success, if output file exits
@testset "Samples        " begin

    samples_dir_path = joinpath(dirname(dirname(@__FILE__)), "samples")
    samples_files = filter(str->endswith(str,".jl"), readdir(samples_dir_path))
    # filter known >= 1.12 -> sample_meshpattern.jl
    if Cairo.libcairo_version < v"1.12.0"
        files_to_exclude = ["sample_meshpattern.jl","sample_record0.jl","sample_record1.jl","sample_script0.jl"]
        samples_files = setdiff(samples_files, files_to_exclude)
    end

    for test_file_name in samples_files
        include(joinpath(samples_dir_path, test_file_name))
        output_png_name = replace(test_file_name,".jl",".png")
        @test isfile(output_png_name)
        rm(output_png_name)
    end
end

# Run some painting, check the colored pixels by counting them
@testset "Bitmap Painting" begin

    include("test_painting.jl")

    # fill all
    z = zeros(UInt32,512,512);
    surf = CairoImageSurface(z, Cairo.FORMAT_ARGB32)
    # fills a 512x512 pixel area with blue,0.5 by using a hilbert curve of
    # dimension 64 (scaled by 8 -> 512) and a linewidth of 8
    hdraw(surf,64,8,8)

    d = simple_hist(surf.data)

    @test length(d) == 1
    @test collect(keys(d))[1] == 0x80000080

    # fill 1/4 (upper quarter)
    z = zeros(UInt32,512,512);
    surf = CairoImageSurface(z, Cairo.FORMAT_ARGB32)
    # fills a 256x256 pixel area with blue,0.5 by using a hilbert curve of
    # dimension 32 (scaled by 8 -> 256) and a linewidth of 8
    hdraw(surf,32,8,8)

    d = simple_hist(surf.data)

    @test length(d) == 2
    @test d[0x80000080] == 256*256

    # fill ~1/2 full,
    z = zeros(UInt32,512,512);
    surf = CairoImageSurface(z, Cairo.FORMAT_ARGB32)
    # fills a 512x512 pixel area with blue,0.5 by using a hilbert curve of
    # dimension 64 (scaled by 8 -> 512) and a linewidth of 4 -> 1/4 of pixels -16
    hdraw(surf,64,8,4)

    d = simple_hist(surf.data)

    @test length(d) == 2
    @test d[0x80000080] == ((512*256)-16)
end

# vector surfaces
@testset "Vector Surfaces" begin

    output_file_name = "a.svg"
    surf = CairoSVGSurface(output_file_name,512,512)
    hdraw(surf,64,8,4)
    finish(surf)

    @test isfile(output_file_name)
    rm(output_file_name)

    io = IOBuffer()
    surf = CairoSVGSurface(io,512,512)
    hdraw(surf,64,8,4)
    finish(surf)

    seek(io,0)
    str_data = Vector{UInt8}(read(io))

    @test length(str_data) > 31000 && str_data[1:13] == [0x3c,0x3f,0x78,0x6d,0x6c,0x20,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e]

    output_file_name = "a.pdf"
    surf = CairoPDFSurface(output_file_name,512,512)
    hdraw(surf,64,8,4)
    finish(surf)

    @test isfile(output_file_name)
    rm(output_file_name)

    io = IOBuffer()
    surf = CairoPDFSurface(io,512,512)
    hdraw(surf,64,8,4)
    finish(surf)

    seek(io,0)
    str_data = Vector{UInt8}(read(io))

    @test length(str_data) > 3000 && str_data[1:7] == [0x25,0x50,0x44,0x46,0x2d,0x31,0x2e]

    output_file_name = "a.eps"
    surf = CairoEPSSurface(output_file_name,512,512)
    hdraw(surf,64,8,4)
    finish(surf)

    @test isfile(output_file_name)
    rm(output_file_name)

    io = IOBuffer()
    surf = CairoEPSSurface(io,512,512)
    hdraw(surf,64,8,4)
    finish(surf)

    seek(io,0)
    str_data = Vector{UInt8}(read(io))

    @test length(str_data) > 3000 && str_data[1:10] == [0x25,0x21,0x50,0x53,0x2d,0x41,0x64,0x6f,0x62,0x65]

    if Cairo.libcairo_version >= v"1.12.0"

        if ~is_windows()

        output_file_name = "a.cs"
        surf = CairoScriptSurface(output_file_name,512,512)
        hdraw(surf,64,8,4)
        destroy(surf)

        @test isfile(output_file_name)

        str_data = read(output_file_name)
        @test length(str_data) > 3000 && str_data[1:10] == [0x25,0x21,0x43,0x61,0x69,0x72,0x6f,0x53,0x63,0x72]
        rm(output_file_name)

        end

        io = IOBuffer()
        surf = CairoScriptSurface(io,512,512)
        hdraw(surf,64,8,4)
        finish(surf)

        seek(io,0)
        str_data = Vector{UInt8}(read(io))

        @test length(str_data) > 3000 && str_data[1:10] == [0x25,0x21,0x43,0x61,0x69,0x72,0x6f,0x53,0x63,0x72]

        if ~is_windows()
        # _create_for_target
        z = zeros(UInt32,512,512);
        surf = CairoImageSurface(z, Cairo.FORMAT_ARGB32)

        output_file_name = "a.cs"
        scsurf = CairoScriptSurface(output_file_name,surf)
        hdraw(scsurf,64,8,8)
        finish(surf)
        destroy(scsurf)
        @test isfile(output_file_name)

        str_data = read(output_file_name)
        @test length(str_data) > 3000 && str_data[1:10] == [0x25,0x21,0x43,0x61,0x69,0x72,0x6f,0x53,0x63,0x72]
        rm(output_file_name)

        d = simple_hist(surf.data)

        @test length(d) == 1
        @test collect(keys(d))[1] == 0x80000080

        end
    end
end

# pixel/bitmap surfaces
@testset "Bitmap Surfaces" begin

    z = zeros(UInt32,512,512);
    surf = CairoImageSurface(z, Cairo.FORMAT_ARGB32)

    hilbert_colored(surf)
    d1 = matrix_read(surf)
    d = simple_hist(d1)

    @test length(d) == 513 # 512 colors and empty background

    surf = CairoARGBSurface(z)

    hilbert_colored(surf)
    d1 = matrix_read(surf)
    d = simple_hist(d1)

    @test length(d) == 513

    surf = CairoRGBSurface(z)

    hilbert_colored(surf)
    d1 = matrix_read(surf)
    d = simple_hist(d1)

    @test length(d) == 512 # black is included
end

@testset "Assert/Status " begin

    z = zeros(UInt32,512,512);
    surf = CairoImageSurface(z, Cairo.FORMAT_ARGB32)

    @test Cairo.status(surf) == 0

    pa = surf.ptr
    surf.ptr = C_NULL

    @test destroy(surf) == nothing

    surf.ptr = pa
    cr = Cairo.CairoContext(surf)

    pa = cr.ptr
    cr.ptr = C_NULL

    @test destroy(cr) == nothing

    @test push_group(cr) == nothing
    @test pop_group(cr) == nothing

    @test_throws AssertionError Cairo.align2offset("to")

    @test_throws ErrorException Cairo.set_line_type(cr,"nondef")
end

nothing