Parameters of the model: free, fixed, constrained

I am seeking advice on the way to store parameters of a model with a metadata free , fixed , or constrained. NamedTuples are already good for the pairs of (:name, :value)

p = (a = 1.1, b = 3.3)

I am considering two options:

  1. A type with the list of parameters with three namedtuple-s
struct Parameters
  free::NamedTuple
  fixed::NamedTuple
  constrained::NamedTuple
end
  1. A parameter type
struct Parameter{T}
  value{T}
  error
  fixed::Bool
  constrained::Bool
end
#
free(v) = Parameter(v,0, false, false)
fixed(v) = Parameter(v,0, true, false)
constrained(v,e) = Parameter(v,e, false, true)
#
p = (a = free(1.1), b = fixed(3.3))

Any thoughts on what the better way is?
Maybe this logic is already implemented somewhere, I would be happy to learn!

Iā€™d probably do the first approach but use

struct Parameters{R,S,T} where {R,S,T}
    free::R
    fixed::S
    constrained::T
end
3 Likes

yes, good point since NamedTuples is parametric.

It really depends on what you do with them, but either way should be fine.