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

mutable struct IoK8sApiCoreV1ResourceQuotaSpec <: SwaggerModel
    hard::Any # spec type: Union{ Nothing, Dict{String, IoK8sApimachineryPkgApiResourceQuantity} } # spec name: hard
    scopeSelector::Any # spec type: Union{ Nothing, IoK8sApiCoreV1ScopeSelector } # spec name: scopeSelector
    scopes::Any # spec type: Union{ Nothing, Vector{String} } # spec name: scopes

    function IoK8sApiCoreV1ResourceQuotaSpec(;hard=nothing, scopeSelector=nothing, scopes=nothing)
        o = new()
        validate_property(IoK8sApiCoreV1ResourceQuotaSpec, Symbol("hard"), hard)
        setfield!(o, Symbol("hard"), hard)
        validate_property(IoK8sApiCoreV1ResourceQuotaSpec, Symbol("scopeSelector"), scopeSelector)
        setfield!(o, Symbol("scopeSelector"), scopeSelector)
        validate_property(IoK8sApiCoreV1ResourceQuotaSpec, Symbol("scopes"), scopes)
        setfield!(o, Symbol("scopes"), scopes)
        o
    end
end # type IoK8sApiCoreV1ResourceQuotaSpec

const _property_map_IoK8sApiCoreV1ResourceQuotaSpec = Dict{Symbol,Symbol}(Symbol("hard")=>Symbol("hard"), Symbol("scopeSelector")=>Symbol("scopeSelector"), Symbol("scopes")=>Symbol("scopes"))
const _property_types_IoK8sApiCoreV1ResourceQuotaSpec = Dict{Symbol,String}(Symbol("hard")=>"Dict{String, IoK8sApimachineryPkgApiResourceQuantity}", Symbol("scopeSelector")=>"IoK8sApiCoreV1ScopeSelector", Symbol("scopes")=>"Vector{String}")
Base.propertynames(::Type{ IoK8sApiCoreV1ResourceQuotaSpec }) = collect(keys(_property_map_IoK8sApiCoreV1ResourceQuotaSpec))
Swagger.property_type(::Type{ IoK8sApiCoreV1ResourceQuotaSpec }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_IoK8sApiCoreV1ResourceQuotaSpec[name]))}
Swagger.field_name(::Type{ IoK8sApiCoreV1ResourceQuotaSpec }, property_name::Symbol) =  _property_map_IoK8sApiCoreV1ResourceQuotaSpec[property_name]

function check_required(o::IoK8sApiCoreV1ResourceQuotaSpec)
    true
end

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


text:
# https://adventofcode.com/2020/day/1
abstract type Day1 <: AocDay end
day1 = Day1

function readinput(::Type{Day1})
    input = parse.(Int, readlines("input/day1.txt"))
    input
end

function entries_sum_to(input, s)
    unique_input = unique(input)
    for entries in Iterators.product(unique_input, unique_input)
        if entries[1] + entries[2] == s
            return entries
        end
    end
end

function entries_sum_to_part2(input, s)
    unique_input = unique(input)
    for entries in Iterators.product(unique_input, unique_input, unique_input)
        if entries[1] + entries[2] + entries[3] == s
            return entries
        end
    end
end

function solve(day::Type{Day1})
    input = readinput(day)

    entries = entries_sum_to(input, 2020)
    result = entries[1] * entries[2]
    result
end

function part2(day::Type{Day1})
    input = readinput(day)

    entries = entries_sum_to_part2(input, 2020)
    result = entries[1] * entries[2] * entries[3]
    result
end

ext: jl


text:
using PyPlot
using CSV
using Dates
include("structures.jl")
include("utilitaires.jl")
include("parser.jl")
include("instance_sur_mesure.jl")
include("concorde.jl")
include("partitionnement_mono.jl")
include("partitionnement_bi.jl")

function main()
    continuer = "o"
    while continuer == "o"
        # Remise à zéro de l'environnement
        reset()

        # Chargement instance
        instance = choixInstance()
        instance.vitesseCamion = 1
        instance.vitesseDrone = 3
        caracteristiquesInstance(instance)
        graphique = initGraphique(instance)

        # Résolution TSP
        resolutionConcorde(instance)
        affichageSolution(instance)
        majGraphique(instance, graphique)

        # Choix mono/bi
        println("\n Choix du type de résolution (TSP-D) :")
        println(" -------------------------------------")
        println("  1) Mono-objectif")
        println("  2) Bi-objectif")
        choix = choixListe(2)
        if choix == "1"
            partitionnementMonoObjectif(instance)
        elseif choix == "2"
            partitionnementBiObjectif(instance)
        end
        affichageSolution(instance)
        majGraphique(instance, graphique)

        # Continuer
        continuer = choixBinaire("\n --> Souhaitez-vous continuer (o/n) ? ")
     end
     close()
end

main()

max_stars_repo_name: xgandibleux/tspd-solver

max_issues_repo_name: xgandibleux/tspd-solver

max_forks_repo_name: xgandibleux/tspd-solver


text:
module TwitterBootstrap

module Layout

using Genie, Genie.Flax

function merge_attributes(elem_attrs::Vector{Pair{Symbol,Any}}, attrs::Pair{Symbol,Any}...) :: Dict{Symbol,Any}
  attributes = Dict(attrs...)

  for (k,v) in attributes
    if startswith(string(k), "data_")
      attributes[Symbol(replace(string(k), r"^data_" => "data-"))] = get!(attributes, k, "")
      delete!(attributes, k)
    end
  end

  for (k,v) in elem_attrs
    attributes[k] = get!(attributes, k, "") * " $v" |> strip
  end

  attributes
end

function breakdowns_to_css_classes(elem::Union{Symbol,String}, breakdowns::Vector{Pair{Symbol,Union{Int,Symbol,String}}})
  classes = String["$elem"]

  for (k,v) in breakdowns
    breakdown = "$elem-"
    k != :any && (breakdown *= string(k) * "-")
    v != :any && (breakdown *= string(v) * "-")
    endswith(breakdown, "-") && (breakdown = breakdown[1:end-1])
    push!(classes, breakdown)
  end

  join(unique!(classes), " ")
end

function container(children::Union{Function,String,Vector{String}} = ""; fluid::Bool = false, attrs...)
  Flax.div(children; merge_attributes(Pair{Symbol,Any}[:class => fluid ? "container-fluid" : "container"], Pair{Symbol,Any}[attrs...]...)...)
end

function row(children::Union{Function,String,Vector{String}} = ""; alignitems::Union{String,Symbol} = "", justifycontent::Union{String,Symbol} = "", nogutters::Bool = false, attrs...)
  classes = String["row"]
  alignitems = string(alignitems)

  if alignitems != ""
    allowed_values = ["start", "center", "end"]
    in(alignitems, allowed_values) || log("alignitems should be one of $allowed_values", :warn)
    push!(classes, "align-items-$alignitems")
  end

  if justifycontent != ""
    allowed_values = ["start", "center", "end", "around", "between"]
    in(justifycontent, allowed_values) || log("alignitems should be one of $allowed_values", :warn)
    push!(classes, "align-items-$justifycontent")
  end

  nogutters && push!(classes, "no-gutters")

  Flax.div(children; merge_attributes(Pair{Symbol,Any}[:class => join(unique!(classes), " ")], Pair{Symbol,Any}[attrs...]...)...)
end

function col(children::Union{Function,String,Vector{String}} = "";
              breakdowns::Vector{Pair{Symbol,Union{Int,Symbol,String}}} = Pair{Symbol,Union{Int,Symbol,String}}[],
              alignself::Union{String,Symbol} = "", attrs...)
  classes = String["col"]

  if alignself != ""
    allowed_values = ["start", "center", "end"]
    in(alignself, allowed_values) || log("alignself should be one of $allowed_values)", :warn)
    push!(classes, "align-self-$alignself")
  end

  push!(classes, breakdowns_to_css_classes("col", breakdowns))

  Flax.div(children; merge_attributes(Pair{Symbol,Any}[:class => join(unique!(classes), " ")], Pair{Symbol,Any}[attrs...]...)...)
end

function colbreak(attrs...)
  Flax.div(; merge_attributes(Pair{Symbol,Any}[:class => "w-100"], Pair{Symbol,Any}[attrs...]...)...)
end

end # Layout

end


text:
using JuMP, EAGO

                     m = Model()

                     EAGO.register_eago_operators!(m)

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

                     @variable(m, -88.40110862821636 <= q <= 80.25263273980681)

                     add_NL_constraint(m, :(softplus(-0.3402051397109518 + -0.28456924845213605*softplus(-0.42610478134649465 + 0.43223652991075534*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.5575457569666615*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.7868073625875285*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.5078849457963623*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.2883931154790984*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.6888193490874222*softplus(-0.17528834888704425 + -0.1425247358809414*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + 0.07932201643104397*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.9443705506849667*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.7094815218028745*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.7352206438426769*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.026837640444652866*softplus(-0.005280183583000753 + 0.6172883711874637*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.07641401576689111*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.42701726221355685*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + -0.5680942985776078*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.9418726475599537*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.08739699596173622*softplus(0.26121381489212014 + -0.018200625348021138*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.03849358234625422*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.856604860683484*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.2143578715735437*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.706261759527687*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.2360509887003217*softplus(-0.09690410604182231 + 0.6473593808554208*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.6752519993458765*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.771479525571356*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.8906247556095672*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.560146720685823*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5])))) + softplus(0.2351041904461102 + 0.11979579421065711*softplus(-0.42610478134649465 + 0.43223652991075534*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.5575457569666615*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.7868073625875285*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.5078849457963623*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.2883931154790984*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.012124046222294904*softplus(-0.17528834888704425 + -0.1425247358809414*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + 0.07932201643104397*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.9443705506849667*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.7094815218028745*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.7352206438426769*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.704332995743346*softplus(-0.005280183583000753 + 0.6172883711874637*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.07641401576689111*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.42701726221355685*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + -0.5680942985776078*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.9418726475599537*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.7162932434639226*softplus(0.26121381489212014 + -0.018200625348021138*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.03849358234625422*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.856604860683484*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.2143578715735437*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.706261759527687*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.3351546298978829*softplus(-0.09690410604182231 + 0.6473593808554208*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.6752519993458765*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.771479525571356*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.8906247556095672*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.560146720685823*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5])))) + softplus(-0.4731175976624935 + -0.5144698215629462*softplus(-0.42610478134649465 + 0.43223652991075534*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.5575457569666615*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.7868073625875285*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.5078849457963623*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.2883931154790984*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.005430014157027596*softplus(-0.17528834888704425 + -0.1425247358809414*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + 0.07932201643104397*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.9443705506849667*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.7094815218028745*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.7352206438426769*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.05201762086802919*softplus(-0.005280183583000753 + 0.6172883711874637*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.07641401576689111*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.42701726221355685*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + -0.5680942985776078*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.9418726475599537*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.06728299071980626*softplus(0.26121381489212014 + -0.018200625348021138*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.03849358234625422*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.856604860683484*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.2143578715735437*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.706261759527687*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.8893971601390014*softplus(-0.09690410604182231 + 0.6473593808554208*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.6752519993458765*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.771479525571356*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.8906247556095672*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.560146720685823*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5])))) + softplus(-0.8380258290664089 + 0.49770714260784343*softplus(-0.42610478134649465 + 0.43223652991075534*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.5575457569666615*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.7868073625875285*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.5078849457963623*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.2883931154790984*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.732919146629087*softplus(-0.17528834888704425 + -0.1425247358809414*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + 0.07932201643104397*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.9443705506849667*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.7094815218028745*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.7352206438426769*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.2983691588163282*softplus(-0.005280183583000753 + 0.6172883711874637*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.07641401576689111*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.42701726221355685*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + -0.5680942985776078*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.9418726475599537*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.6200389337758314*softplus(0.26121381489212014 + -0.018200625348021138*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.03849358234625422*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.856604860683484*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.2143578715735437*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.706261759527687*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.03199113104777407*softplus(-0.09690410604182231 + 0.6473593808554208*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.6752519993458765*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.771479525571356*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.8906247556095672*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.560146720685823*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5])))) + softplus(0.7168755118620993 + -0.38856981611164576*softplus(-0.42610478134649465 + 0.43223652991075534*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.5575457569666615*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.7868073625875285*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.5078849457963623*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.2883931154790984*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.9818525806719265*softplus(-0.17528834888704425 + -0.1425247358809414*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + 0.07932201643104397*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.9443705506849667*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.7094815218028745*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + -0.7352206438426769*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.9400532013818674*softplus(-0.005280183583000753 + 0.6172883711874637*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.07641401576689111*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.42701726221355685*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + -0.5680942985776078*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.9418726475599537*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + -0.928831604242299*softplus(0.26121381489212014 + -0.018200625348021138*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.03849358234625422*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + -0.856604860683484*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.2143578715735437*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.706261759527687*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5]))) + 0.6913287958041021*softplus(-0.09690410604182231 + 0.6473593808554208*softplus(-0.9360387382859474 + 0.27356363334073697*$(x[1]) + 0.5623428270051978*$(x[2]) + -0.9519487490584724*$(x[3]) + 0.5639775172803199*$(x[4]) + 0.8360124736609604*$(x[5])) + -0.6752519993458765*softplus(0.3895701371443887 + 0.5298392176190725*$(x[1]) + -0.9900818182438851*$(x[2]) + 0.9005096697487907*$(x[3]) + 0.008235253700211498*$(x[4]) + 0.03120241694369552*$(x[5])) + 0.771479525571356*softplus(0.7802421455771191 + -0.3899284089358539*$(x[1]) + -0.510799262552962*$(x[2]) + -0.16925880893067768*$(x[3]) + -0.7702701325797845*$(x[4]) + -0.21353502867805174*$(x[5])) + 0.8906247556095672*softplus(-0.4643333519515682 + -0.743154946296293*$(x[1]) + 0.08142803382004216*$(x[2]) + 0.8067509325852682*$(x[3]) + -0.6642228946665827*$(x[4]) + -0.03791136441363552*$(x[5])) + 0.560146720685823*softplus(0.6488423858989929 + -0.3655334329180211*$(x[1]) + 0.8449912783652063*$(x[2]) + -0.7635680273216123*$(x[3]) + 0.17014039681297044*$(x[4]) + -0.14496676502055283*$(x[5])))) - $q <= 0.0))

                     @objective(m, Min, q)

                     return m

max_stars_repo_name: PSORLab/RSActivationFunctions

max_issues_repo_name: PSORLab/RSActivationFunctions

max_forks_repo_name: PSORLab/RSActivationFunctions


text:
using BenchmarkTools, Plots, Plots.PlotMeasures, LaTeXStrings
using BenchmarkTools: minimum, median

SUITE = BenchmarkGroup()
SUITE["Quadrotor"] = BenchmarkGroup()

# ==============================================================================
# Jet-based approach using Taylor Models
# ==============================================================================
include("quadrotor.jl")

𝑃, 𝑂 = quad(project_reachset=false)

# algorithm-specific options
𝑂jets = Options(:abs_tol=>1e-7, :orderT=>5, :orderQ=>1, :max_steps=>500)

# first run
sol = solve(𝑃, 𝑂, op=TMJets(𝑂jets))

# benchmark
SUITE["Quadrotor"]["Specification"] = @benchmarkable solve($𝑃, $𝑂, op=TMJets($𝑂jets))

# ==============================================================================
# Execute benchmarks and save benchmark results
# ==============================================================================

# tune parameters
tune!(SUITE)

# run the benchmarks
results = run(SUITE, verbose=true)

# return the sample with the smallest time value in each test
println("minimum time for each benchmark:\n", minimum(results))

# return the median for each test
println("median time for each benchmark:\n", median(results))

# ==============================================================================
# Create plots
# ==============================================================================

𝑃, 𝑂 = quad(project_reachset=true)
sol = solve(𝑃, 𝑂, op=TMJets(𝑂jets))

plot(sol,
     tickfont=font(30, "Times"), guidefontsize=45,
     xlab=L"t\raisebox{-0.5mm}{\textcolor{white}{.}}",
     ylab=L"x_{3}\raisebox{1mm}{\textcolor{white}{.}}",
     xtick=[0., 1, 2, 3, 4, 5], ytick=[0.5, 0., 0.5, 1.0, 1.5],
     xlims=(0., 5.), ylims=(-0.5, 1.5),
     bottom_margin=6mm, left_margin=6mm, right_margin=4mm, top_margin=3mm,
     size=(1000, 1000), linecolor="blue")

plot!(x->x, x->1.4, 0., 5., line=2, color="red", linestyle=:dash, legend=nothing)
plot!(x->x, x->0.98, 0., 5., line=2, color="red", linestyle=:dash, legend=nothing)
plot!(x->x, x->1.02, 0., 5., line=2, color="red", linestyle=:dash, legend=nothing)
plot!(x->x, x->0.9, 0., 5., line=2, color="red", linestyle=:dash, legend=nothing)

savefig(@relpath "quadrotor.png")

max_stars_repo_name: JuliaReach/ReachabilityBenchmarks

max_issues_repo_name: Aadesha/ReachabilityBenchmarks

max_forks_repo_name: Aadesha/ReachabilityBenchmarks


text:
module Kriging

#
#  The Kriging module provides two types of service:
#
#  * universal kriging with isotropic covariance or correlation
#  * trend surface model kriging
#
#

using Stations
import Stations.nearest_grid_point, Stations.obs_variance, Stations.obs_value

using Storage
import Storage.spush

function numerical_solve_bisect(e2, eps2, k)

    N = size(e2,1)
    tgt = N - k
    s2_eta_left = 0.0
    s2_eta_right = 0.1

    val_left = sum(e2 ./ eps2)
    val_right = sum(e2 ./ (eps2 + s2_eta_right))
    if val_left < tgt
        return -1.0
    end

    while val_right > tgt
        s2_eta_right *= 2.0
        val_right = sum(e2 ./ (eps2 + s2_eta_right))
    end

    # bisection implementation (initialized with s2_eta = 0)
    while val_left - val_right > 1e-6

        # compute new value at center of eta interval
        s2_eta = 0.5 * (s2_eta_left + s2_eta_right)
        val = sum(e2 ./ (eps2 + s2_eta))

        if val > tgt
            val_left, s2_eta_left = val, s2_eta
        else
            val_right, s2_eta_right = val, s2_eta
        end

    end

    return 0.5 * (s2_eta_left + s2_eta_right)

end

function trend_surface_model_kriging(obs_data, X, K, V)
    """
    Trend surface model kriging, which assumes spatially uncorrelated errors.

    WARNING: The variable X is clobbered.

    The kriging results in the matrix K, which contains the kriged observations
    and the matrix V, which contains the kriging variance.
    """
    Nobs = length(obs_data)
    Ncov_all = size(X,3)

    dsize = size(X)[1:2]
    y = zeros((Nobs,1))
    m_var = zeros(Nobs)

    Xobs = zeros(Nobs, Ncov_all)
    for (obs,i) in zip(obs_data, 1:Nobs)
    	p = nearest_grid_point(obs)
        y[i] = obs_value(obs)
        Xobs[i,:] = X[p[1], p[2], :]
        m_var[i] = obs_variance(obs)
    end

    # if we have covariates full of zeros (e.g. there is no rain in the entire domain at
    # the current simulation time), we must exclude them or a singular exception
    # will be thrown by '\'
    cov_ids = find(map(i -> sum(Xobs[:,i].^2) > 0, 1:Ncov_all))
    Ncov = length(cov_ids)
    X = X[:,:,cov_ids]
    Xobs = Xobs[:, cov_ids]

    # if there are less observations than covariates, remove
    # Ncov - Nobs covariates from end
    if Ncov > Nobs
        Ncov = Nobs
        cov_ids = cov_ids[1:Ncov]
        X = X[:,:,1:Ncov]
        Xobs = Xobs[:, 1:Ncov]
    end

    # quick pre-conditioning hack
    # rescale all columns of Xobs to have norm of first column
    norm_1 = sum(Xobs[:,1].^2)^0.5
    for i in 2:Ncov
        norm_i = sum(Xobs[:,i].^2)^0.5
        if norm_i > 0.0
            Xobs[:,i] *= norm_1 / norm_i
            X[:,:,i] *= norm_1 / norm_i
        end
    end

    # initialize iterative algorithm
    s2_eta_hat_old = 10.0
    s2_eta_hat = 0.0
    XtSX = nothing
    beta = nothing

    iters = 0
    subzeros = 0

    # the while loop contains protection against division by zero in case s2_eta_hat_old
    # is below zero (happens if the estimate of s2_eta_hat fails and this gets copied into s2_eta_hat_old)
    while abs( (s2_eta_hat_old - s2_eta_hat) / max(s2_eta_hat_old, 1e-8)) > 1e-2

        # shift current estimate to old var
        s2_eta_hat_old = s2_eta_hat

        # recompute the covariance matrix
        Sigma = diagm(m_var) + s2_eta_hat * eye(Nobs)
        XtSX = Xobs' * (Sigma \ Xobs)

        # QR solution method of least squares
        Sigma_1_2 = diagm(diag(Sigma).^-0.5)   # Sigma^(-1/2)
        yt = Sigma_1_2 * y
        Q, R = qr(Sigma_1_2 * Xobs)
        beta = R \ (Q' * yt)
        res = y - Xobs * beta

        # compute new estimate of variance of microscale variability
        s2_array = res.^2 - m_var
        for j in 1:Nobs
            s2_array[j] += dot(vec(Xobs[j,:]), vec(XtSX \ Xobs[j,:]'))
        end
        s2_eta_hat2 = sum(s2_array) / Nobs

        # solve equation by bisection
        s2_eta_hat = numerical_solve_bisect(res.^2, m_var, Ncov)
        if s2_eta_hat < 0.0
            s2_eta_hat = 0.0
            println("TSM: s2_eta_hat estimate below zero, culling to zero.")
        end

        subzeros = sum(s2_array .< 0)
        iters += 1
    end

    # compute the OLS fit of the covariates to the observations
    spush("kriging_xtx_cond", cond(XtSX))
    spush("kriging_errors", (y - Xobs * beta)')

    # printing construction that makes sure order of printed betas does not vary
    # across times even if there are zero covariates
    beta_ext = ones((Ncov_all,1)) * NaN
    beta_ext[cov_ids] = beta
    spush("kriging_beta", beta_ext)

    spush("kriging_sigma2_eta", s2_eta_hat)
    spush("kriging_iters", iters)
    spush("kriging_subzero_s2_estimates", subzeros)

    # compute kriging field and kriging variance
    for i in 1:dsize[1]
        for j in 1:dsize[2]
            x_ij = squeeze(X[i,j,:], 1)'   # convert covariates at position i,j into a column vector
            K[i,j] = dot(vec(x_ij), vec(beta))
            V[i,j] = s2_eta_hat + dot(vec(x_ij), vec(XtSX \ x_ij))
        end
    end

end

end


text:
"""
    HTML_TOKENS

Dictionary of tokens for HTML. See also [`MD_TOKENS`](@ref).
"""
const HTML_TOKENS = LittleDict{Char, Vector{Pair{TokenFinder, Symbol}}}(
    '{' => [
        forward_match("{{") => :DBB_OPEN
        ],
    '}' => [
        forward_match("}}") => :DBB_CLOSE
        ],
    '<' => [
        forward_match("<!--")                => :COMMENT_OPEN,
        forward_match("<script", [' ', '>']) => :SCRIPT_OPEN,  # [1]
        forward_match("</script>")           => :SCRIPT_CLOSE
        ],
    '-' => [
        forward_match("-->") => :COMMENT_CLOSE
        ]
    )
#
# [1] note that we don't capture the closing `>` so for an application where the user
# would want to extract the content in a script block; they would have to post-filer
# the result of `content` to find the first `>` character and start from there.
# We don't do that by default because in Franklin we ignore script blocks completely.
#


text:
using PkgServer, Pkg, Pkg.TOML, HTTP, JSON3, Tar, Test

# You can either perform the following setup:
#  - Already-running PkgServer, located at $JULIA_PKG_SERVER
#  - PkgServer cache directory located at $PKG_SERVER_CACHE_DIR
#
# Or you can leave those blank, and we'll start up a PkgServer for you,
# running on a background process.

if VERSION < v"1.5"
    error("These tests require a PkgServer-compatible Julia version!")
end

# "Backport" of JuliaLang/julia#37206
function prepare_for_deletion(path::AbstractString)
    # Nothing to do for non-directories
    if !isdir(path)
        return
    end

    try chmod(path, filemode(path) | 0o333)
    catch; end
    for (root, dirs, files) in walkdir(path)
        for dir in dirs
            dpath = joinpath(root, dir)
            try chmod(dpath, filemode(dpath) | 0o333)
            catch; end
        end
    end
end

# If these are not set, we will attempt to auto-initiate them.
server_process = nothing
if isempty(get(ENV, "JULIA_PKG_SERVER", "")) || isempty(get(ENV, "JULIA_PKG_SERVER_STORAGE_ROOT", ""))
    # Start a background PkgServer as a separate process
    code_dir = dirname(@__DIR__)
    temp_dir = mktempdir()
    ENV["JULIA_PKG_SERVER"] = "http://127.0.0.1:8000"
    ENV["JULIA_PKG_SERVER_STORAGE_ROOT"] = temp_dir

    @info("Automatically starting local PkgServer for testing at $(ENV["JULIA_PKG_SERVER"])")
    global server_process = run(`$(Base.julia_cmd()) --project=$(code_dir) $(code_dir)/bin/run_server.jl`; wait=false)
end

server_url = ENV["JULIA_PKG_SERVER"]
cache_dir = joinpath(ENV["JULIA_PKG_SERVER_STORAGE_ROOT"], "cache")

# Wrap all tests in a `try` block so that we can be certain we kill the
# server, even if we fail some tests.
try
    @info("Running test suite with configuration", server_url, cache_dir)
    include("tests.jl")
finally
    if server_process != nothing
        @info("Reaping automatically-started local PkgServer...")
        kill(server_process)
        wait(server_process)
        @info("Outputting testing PkgServer logs:")
        for f in filter(f -> endswith(f, "-pkgserver.log"), readdir("$(temp_dir)/logs"; join=true))
            println("$(f):")
            write(stdout, read(f))
        end
    end
end

(@isdefined temp_dir) && prepare_for_deletion(temp_dir)


text:
using BinaryBuilder

name = "SDG"
version = v"0.0.1"

sources = [
    "https://github.com/bioinfologics/sdg.git" =>
    "99b23a652fcd34f10d7648493297dbdfcc83a3ce",
]

script = raw"""
cd $WORKSPACE/srcdir
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_TOOLCHAIN_FILE=/opt/$target/$target.toolchain -DCMAKE_FIND_ROOT_PATH=${prefix} ../sdg
make
make install
"""

# These are the platforms we will build for by default, unless further
# platforms are passed in on the command line
platforms = Platform[
    Linux(:x86_64, compiler_abi = CompilerABI(:gcc7)),
    Linux(:aarch64, compiler_abi = CompilerABI(:gcc7)),
    Linux(:powerpc64le, compiler_abi = CompilerABI(:gcc7)),
    MacOS(:x86_64, compiler_abi = CompilerABI(:gcc7)),
    FreeBSD(:x86_64, compiler_abi = CompilerABI(:gcc7))
]

# The products that we will ensure are always built
products(prefix) = [
    LibraryProduct(prefix, "libsdg", :libsdg)
]

# Dependencies that must be installed before this package can be built
dependencies = [
    "https://github.com/staticfloat/Bzip2Builder/releases/download/v1.0.6-1/build_Bzip2.v1.0.6.jl",
    "https://github.com/BenJWard/ZLibBuilder/releases/download/v1.2.11/build_ZLibBuilder.v1.2.11.jl"
]

build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies)

max_stars_repo_name: BenJWard/SDGBuilder

max_issues_repo_name: BenJWard/SDGBuilder

max_forks_repo_name: BenJWard/SDGBuilder


text:
using Requires
using Compat
import Base.convert

write_patchwork_prelude(io::IO) =
    write(io, "<script>", Patchwork.js_runtime(), "</script>")

write_escher_prelude(io::IO) = begin
    write(io, Escher.custom_elements())
    write_patchwork_prelude(io)
end

# FIXME: figure out a way to make this work for Escher
#
# immutable EscherDisplay <: Base.Display end
#
# pushdisplay(EscherDisplay())

@require IJulia begin
    # Load custom element definitions

    using IJulia.CommManager
    import Base.Random: UUID, uuid4

    setup_transport(sig::Signal) = begin
        id = makeid(sig)
        comm = Comm(:EscherSignal, data=@d(:signalId => id))
        comm.on_msg = (msg) ->
            push!(sig, decodeJSON(sig, msg.content["data"]["value"]))
        return id
    end
end

export drawing

# A declarative version of draw?
Escher.@api drawing => (ComposeGraphic <: Escher.Tile) begin
    arg(img::Any)
    arg(graphic::Any) # Either a plot or a compose node
end

@require ComposeDiff begin
    if !(try Pkg.installed("ComposeDiff") > v"0.0.0" catch err false end)
        error("You need to install the ComposeDiff package to use Gadfly or Compose in Escher.")
    end

    Escher.drawing(w::Compose.Measure, h::Compose.Measure, p) =
        Escher.drawing(ComposeDiff.Patchable(w, h), p)

    Escher.drawing(w::Compose.Measure, h::Compose.Measure) = p -> Escher.drawing(w, h, p)

    Escher.drawing(p) =
        Escher.drawing(Compose.default_graphic_width, Compose.default_graphic_height, p)

    compose_render(img::ComposeDiff.Patchable, pic) = begin
        Compose.draw(img, pic)
    end

    compose_render(img, pic) = begin
        Compose.draw(img, pic) # do the drawing side-effect
        Elem(:img, src="""data:image/png;base64,$(base64(takebuf_array(img.out)))""")
    end

    Escher.render(d::Escher.ComposeGraphic, state) = begin
        Elem(:div, compose_render(d.img, d.graphic), className="graphic-wrap")
    end

    convert(::Type{Tile}, p::Compose.Context) =
        Escher.drawing(p)
end

@require Compose begin
    using ComposeDiff
end

@require Gadfly begin
    import Gadfly: Compose

    using ComposeDiff
    convert(::Type{Tile}, p::Gadfly.Plot) =
        Escher.drawing(
            ComposeDiff.Patchable(
                Compose.default_graphic_width,
                Compose.default_graphic_height), p)
end

@require DataFrames begin
    include(Pkg.dir("Escher", "src", "library", "table.jl"))

    import DataFrames: AbstractDataFrame

    convert(::Type{Tile}, df::AbstractDataFrame) = table(df)
end

@require Blink begin
    include("blink.jl")
end

@require SymPy begin
    convert(::Type{Tile}, s::SymPy.Sym) =
        tex(SymPy.latex(s))
end

@require Images begin
    convert(::Type{Tile}, img::Images.Image) =
        Escher.image("data:image/png;base64," * stringmime(MIME"image/png"(), img))
end


text:
include("utilities.jl")

using SEAL
using Printf

"""
    example_ckks_basics()

Perform some basic operations such as encryption/decryption, multiplication, addition etc. using the
CKKS scheme. This routine is based on the file `native/examples/4_ckks_basics.cpp` of the original
SEAL library and should yield the exact same output.

* [SEAL](https://github.com/microsoft/SEAL)
* [native/examples/4_ckks_basics.cpp](https://github.com/microsoft/SEAL/blob/master/native/examples/4_ckks_basics.cpp)

See also: [`example_ckks_basics`](@ref)
"""
function example_ckks_basics()
  print_example_banner("Example: CKKS Basics")

  parms = EncryptionParameters(SchemeType.ckks)

  poly_modulus_degree = 8192
  set_poly_modulus_degree!(parms, poly_modulus_degree)
  set_coeff_modulus!(parms, coeff_modulus_create(poly_modulus_degree, [60, 40, 40, 60]))

  initial_scale = 2.0^40

  context = SEALContext(parms)
  print_parameters(context)
  println()

  keygen = KeyGenerator(context)
  public_key_ = PublicKey()
  create_public_key!(public_key_, keygen)
  secret_key_ = secret_key(keygen)
  relin_keys_ = RelinKeys()
  create_relin_keys!(relin_keys_, keygen)
  encryptor = Encryptor(context, public_key_)
  evaluator = Evaluator(context)
  decryptor = Decryptor(context, secret_key_)

  encoder = CKKSEncoder(context)
  slot_count_ = slot_count(encoder)
  println("Number of slots: ", slot_count_)

  input = collect(range(0.0, 1.0, length=slot_count_))
  println("Input vector:")
  print_vector(input, 3, 7)

  println("Evaluating polynomial PI*x^3 + 0.4x + 1 ...")

  plain_coeff3 = Plaintext()
  plain_coeff1 = Plaintext()
  plain_coeff0 = Plaintext()
  encode!(plain_coeff3, 3.14159265, initial_scale, encoder)
  encode!(plain_coeff1, 0.4, initial_scale, encoder)
  encode!(plain_coeff0, 1.0, initial_scale, encoder)

  x_plain = Plaintext()
  print_line(@__LINE__)
  println("Encode input vectors.")
  encode!(x_plain, input, initial_scale, encoder)
  x1_encrypted = Ciphertext()
  encrypt!(x1_encrypted, x_plain, encryptor)

  x3_encrypted = Ciphertext()
  print_line(@__LINE__)
  println("Compute x^2 and relinearize:")
  square!(x3_encrypted, x1_encrypted, evaluator)
  relinearize_inplace!(x3_encrypted, relin_keys_, evaluator)
  println("    + Scale of x^2 before rescale: ", log2(scale(x3_encrypted)), " bits")

  print_line(@__LINE__)
  println("Rescale x^2.")
  rescale_to_next_inplace!(x3_encrypted, evaluator)
  println("    + Scale of x^2 after rescale: ", log2(scale(x3_encrypted)), " bits")

  print_line(@__LINE__)
  println("Compute and rescale PI*x.")
  x1_encrypted_coeff3 = Ciphertext()
  multiply_plain!(x1_encrypted_coeff3, x1_encrypted, plain_coeff3, evaluator)
  println("    + Scale of PI*x before rescale: ", log2(scale(x1_encrypted_coeff3)), " bits")
  rescale_to_next_inplace!(x1_encrypted_coeff3, evaluator)
  println("    + Scale of PI*x after rescale: ", log2(scale(x1_encrypted_coeff3)), " bits")

  print_line(@__LINE__)
  println("Compute, relinearize, and rescale (PI*x)*x^2.")
  multiply_inplace!(x3_encrypted, x1_encrypted_coeff3, evaluator)
  relinearize_inplace!(x3_encrypted, relin_keys_, evaluator)
  println("    + Scale of PI*x^3 before rescale: ", log2(scale(x3_encrypted)), " bits")
  rescale_to_next_inplace!(x3_encrypted, evaluator)
  println("    + Scale of PI*x^3 after rescale: ", log2(scale(x3_encrypted)), " bits")

  print_line(@__LINE__)
  println("Compute and rescale 0.4*x.")
  multiply_plain_inplace!(x1_encrypted, plain_coeff1, evaluator)
  println("    + Scale of 0.4*x before rescale: ", log2(scale(x1_encrypted)), " bits")
  rescale_to_next_inplace!(x1_encrypted, evaluator)
  println("    + Scale of 0.4*x after rescale: ", log2(scale(x1_encrypted)), " bits")

  println()
  print_line(@__LINE__)
  println("Parameters used by all three terms are different.")
  ci_x3 = chain_index(get_context_data(context, parms_id(x3_encrypted)))
  println("    + Modulus chain index for x3_encrypted: ", ci_x3)
  ci_x1 = chain_index(get_context_data(context, parms_id(x1_encrypted)))
  println("    + Modulus chain index for x1_encrypted: ", ci_x1)
  ci_c0 = chain_index(get_context_data(context, parms_id(plain_coeff0)))
  println("    + Modulus chain index for plain_coeff0: ", ci_c0)
  println()

  print_line(@__LINE__)
  println("The exact scales of all three terms are different:")
  @printf("    + Exact scale in PI*x^3: %.10f\n", scale(x3_encrypted))
  @printf("    + Exact scale in  0.4*x: %.10f\n", scale(x1_encrypted))
  @printf("    + Exact scale in      1: %.10f\n", scale(plain_coeff0))
  println()

  print_line(@__LINE__)
  println("Normalize scales to 2^40.")
  scale!(x3_encrypted, 2.0^40)
  scale!(x1_encrypted, 2.0^40)

  print_line(@__LINE__)
  println("Normalize encryption parameters to the lowest level.")
  last_parms_id = parms_id(x3_encrypted)
  mod_switch_to_inplace!(x1_encrypted, last_parms_id, evaluator)
  mod_switch_to_inplace!(plain_coeff0, last_parms_id, evaluator)

  print_line(@__LINE__)
  println("Compute PI*x^3 + 0.4*x + 1.")
  encrypted_result = Ciphertext()
  add!(encrypted_result, x3_encrypted, x1_encrypted, evaluator)
  add_plain_inplace!(encrypted_result, plain_coeff0, evaluator)

  plain_result = Plaintext()
  print_line(@__LINE__)
  println("Decrypt and decode PI*x^3 + 0.4x + 1.")
  println("    + Expected result:")
  true_result = similar(input)
  for (i, x) in enumerate(input)
    true_result[i] = (3.14159265 * x * x + 0.4) * x + 1
  end
  print_vector(true_result, 3, 7)

  decrypt!(plain_result, encrypted_result, decryptor)
  result = similar(input)
  decode!(result, plain_result, encoder)
  println("    + Computed result ...... Correct.")
  print_vector(result, 3, 7)

  return
end


text:
module TestMaterialize

include("preamble.jl")
using BangBang: air

@testset begin
    @test materialize!!(nothing, air.([0, 1] .+ 2))::Vector{Int} == [2, 3]
    @test materialize!!([NaN, NaN], air.([0, 1] .+ 2))::Vector{Real} == [2, 3]
    @test materialize!!(nothing, air.((0, 1) .+ 2))::Tuple === (2, 3)
    @test materialize!!(nothing, air.(SVector(0, 1) .+ 2))::SVector === SVector(2, 3)
end

@testset "widen" begin
    a0 = Real[1:3;]
    a = copy(a0)
    b = [0im] .+ (1:3)
    c = materialize!!(a, air.(a .+ b))
    @test c == a .+ b
    @test a == a0  # not modified
end

@testset "type-unstable materialize!!" begin
    unstabletrue = Ref{Any}(true)
    unstableone(unused) = unstabletrue[] ? unstabletrue[] : unused
    @test materialize!!(nothing, air.([1] .+ unstableone.([0]) ./ [1])) == [2]
end

end  # module


text:
#############################################################################
#Copyright (c) 2016 Charles Le Losq
#
#The MIT License (MIT)
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the #Software without restriction, including without limitation the rights to use, copy, #modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, #and to permit persons to whom the Software is furnished to do so, subject to the #following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, #INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Temperature and laser wavelength effects correction for Raman spectra
# Charles Le Losq
# RSES-ANU 2016
# Long's correction of Raman spectra and normalisation
# last rev. Oct 2016 for convertion in Julia
# ensures strictly increasing values of wavenumber
# calc. e.s.e. as Long cor. norm. sqrt(n_raw) 3d output col.
# exp. format to avoid null ese.
#
# THOSE FORMULA ARE WRITTEN FOR STOKES RAMAN. May be easily adapted for anti-Stokes upon request.
#
# References
# Shuker, Reuben, and Robert Gammon. 1970. “Raman-Scattering Selection-Rule Breaking and the Density of States in Amorphous Materials.” Physical Review Letters 25 (4): 222–25.
# Galeener, F. L., and Sen, P. N. 1978. “Theory of the First-Order Vibrational Spectra of Disordered Solids.” Physical Review B 17 (4): 1928–33.
# Mysen, B. O., L. W. Finger, D. Virgo, and F. A. Seifert. 1982. “Curve-Fitting of Raman Spectra of Silicate Glasses.” American Mineralogist 67: 686–95.
# Brooker et al. 1988 Assessment of correction procedures for reduction of Raman spectra. Journal of Raman Spectroscopy 19(2), 71-78.
# Neuville, D. R., and B. O. Mysen. 1996. “Role of Aluminium in the Silicate Network: In Situ, High-Temperature Study of Glasses and Melts on the Join SiO₂-NaAl0₂.” Geochimica et Cosmochimica Acta 60: 1727–37.
# Le Losq, C., D. R. Neuville, R. Moretti, and J. Roux. 2012. “Determination of Water Content in Silicate Glasses Using Raman Spectrometry: Implications for the Study of Explosive Volcanism.” American Mineralogist 97 (5-6): 779–90. doi:10.2138/am.2012.3831.
# Hehlen, B. 2010. “Inter-Tetrahedra Bond Angle of Permanently Densified Silicas Extracted from Their Raman Spectra.” Journal of Physics: Condensed Matter 22 (2): 025401.
#############################################################################

function tlcorrection(data::Array{Float64},temp::Float64,wave::Float64;correction="long",normalisation="area",density=2210.0)

    h::Float64 = 6.626070040e-34   # J S    Plank constant from NIST
	hb::Float64 = 1.054571800e-34 # J S    Reduced Plank constant from NIST
    k::Float64 = 1.38064852e-23      # J K-1    Boltzman constant from NIST
    c::Float64 = 299792458.         # M S-1    Speed of light from NIST
    nu0::Float64 = 1.0./wave*1e9     # nu0 laser is in M-1 (wave is in nm)
    T::Float64 = temp + 273.15    # K temperature
	# density is in KG M-3

    x::Array{Float64} = data[:,1]
    y::Array{Float64} = data[:,2]

    # Calculate the error on data as sqrt(y). If y <= 0, then error = abs(y).
    ese::Array{Float64} = sqrt(abs(y))./abs(y) # relative errors

	# get the Raman shift in m-1
	nu::Array{Float64} = 100.0.*x # cm-1 -> m-1 Raman shift

    # then we proceed to the correction
	if correction == "long"
		# Formula used in Mysen et al. (1982), Neuville and Mysen (1996) and Le Losq et al. (2012) (corrected for using the Planck constant in the last reference)
		# It is that reported in Brooker et al. (1988) with the addition of a scaling nu0^3 coefficient for adimentionality
    	frequency::Array{Float64} = nu0.^3.*nu./((nu0-nu).^4) # frequency correction; dimensionless
    	boltzman::Array{Float64} = 1 - exp(-h.*c.*nu./(k.*T)) # temperature correction with Boltzman distribution; dimensionless
    	ycorr::Array{Float64} = y.*frequency.*boltzman; # correction

	elseif correction == "galeener"
		# This uses the formula reported in Galeener and Sen (1978) and Brooker et al. (1988); it uses the Bose-Einstein / Boltzman distribution
		# Formula from  without the scaling vo^3 coefficient reported in Mysen et al. (1982), Neuville and Mysen (1996) and Le Losq et al. (2012)
    	frequency = nu./((nu0-nu).^4) # frequency correction; M^3
    	boltzman = 1 - exp(-h.*c.*nu./(k.*T)) # temperature correction with Boltzman distribution; dimensionless
    	ycorr = y.*frequency.*boltzman; # correction

	elseif correction =="hehlen"
		# this uses the formula reported in Hehlen et al. 2010
    	frequency = nu./(nu0.^3.*density) # frequency + density correction; M/KG
    	boltzman = 1 - exp(-h.*c.*nu./(k.*T)) # dimensionless
    	ycorr = y.*frequency.*boltzman; # correction
	else
		error("Not implemented, choose between long, galeener or hehlen.")
	end

	if normalisation == "area"
    	ycorr = ycorr./trapz(x,ycorr) # area normalisation
	elseif normalisation == "intensity"
		ycorr= ycorr./maximum(ycorr) # max. intensity normalisation
	elseif normalisation == "no"
		# nothing will happen
	else
		error("Set the optional normalisation parameter to area, intensity or no.")
	end

    esecorr::Array{Float64} = ese.*ycorr # error calculation

    return x, ycorr, esecorr
end


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

using GERDAMetadata
using Test

@testset "filekey" begin
    key = FileKey("gerda-run0068-20160718T064953Z-phy")
    @test string(key) == "gerda-run0068-20160718T064953Z-phy"

    @test occursin(key, "%-run0068-%-phy")
    @test !occursin(key, "%-run0069-%-phy")

    @test FileKey("gerda-run0068-20160718T064953Z-phy") == key
end


text:
"""
    Pathfinding.CostMetric{D}
An abstract type representing a metric that measures the approximate cost of travelling
between two points in a `D` dimensional [`GridSpace{D}`](@ref).
"""
abstract type CostMetric{D} end

struct DirectDistance{D} <: CostMetric{D}
    direction_costs::Vector{Int}
end

"""
    Pathfinding.DirectDistance{D}([direction_costs::Vector{Int}]) <: CostMetric{D}
Distance is approximated as the shortest path between the two points, provided the
`walkable` property of [`Pathfinding.Pathfinder`](@ref) allows.
Optionally provide a `Vector{Int}` that represents the cost of going from a tile to the
neighboring tile on the `i` dimensional diagonal (default is `10√i`).

If `diagonal_movement=false` in [`Pathfinding.Pathfinder`](@ref), neighbors in diagonal
positions will be excluded. Cost defaults to the first value of the provided vector.
"""
DirectDistance{D}() where {D} = DirectDistance{D}([floor(Int, 10.0 * √x) for x in 1:D])

Base.show(io::IO, metric::DirectDistance) = print(io, "DirectDistance")

"""
    Pathfinding.MaxDistance{D}() <: CostMetric{D}
Distance between two tiles is approximated as the maximum of absolute
difference in coordinates between them.
"""
struct MaxDistance{D} <: CostMetric{D} end

Base.show(io::IO, metric::MaxDistance) = print(io, "MaxDistance")

struct HeightMap{D} <: CostMetric{D}
    base_metric::CostMetric{D}
    hmap::Array{Int,D}
end

"""
    Pathfinding.HeightMap(hmap::Array{Int,D} [, base_metric::CostMetric]) <: CostMetric{D}
Distance between two positions is the sum of the shortest distance between them and the
absolute difference in height. A heightmap of the same size as the corresponding
[`GridSpace{D}`](@ref) is required. Distance is calculated using [`Pathfinding.DirectDistance`](@ref)
by default, and can be changed by specifying `base_metric`. An example usage can be found in
[Mountain Runners](@ref).
"""
HeightMap(hmap::Array{Int,D}) where {D} = HeightMap{D}(DirectDistance{D}(), hmap)

HeightMap(hmap::Array{Int,D}, base_metric::CostMetric{D}) where {D} =
    HeightMap{D}(base_metric, hmap)

Base.show(io::IO, metric::HeightMap) =
    print(io, "HeightMap with base: $(metric.base_metric)")


text:
include(Pkg.dir("AutomotiveDrivingModels", "test", "evaluation", "test_foldsets.jl"))
include(Pkg.dir("AutomotiveDrivingModels", "test", "evaluation", "test_fold_assigners.jl"))
include(Pkg.dir("AutomotiveDrivingModels", "test", "evaluation", "test_trajdata_segments.jl"))
include(Pkg.dir("AutomotiveDrivingModels", "test", "evaluation", "test_evaluation_data.jl"))