# Parameters of the model: free, fixed, constrained

**URL:** <https://discourse.julialang.org/t/parameters-of-the-model-free-fixed-constrained/53501>\
**Category:** General Usage\
**Created:** [January 17, 2021, 9:49pm UTC](https://discourse.julialang.org/t/parameters-of-the-model-free-fixed-constrained/53501 "2021-01-17T21:49:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![misha\_mikhasenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/misha_mikhasenko/32/5060_2.png) [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Post date:** [January 17, 2021, 9:49pm UTC](https://discourse.julialang.org/t/parameters-of-the-model-free-fixed-constrained/53501/1 "2021-01-17T21:49:17Z")

</div>

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)

```julia
p = (a = 1.1, b = 3.3)

```

I am considering two options:

1. A type with the list of parameters with three namedtuple-s

```julia
struct Parameters
  free::NamedTuple
  fixed::NamedTuple
  constrained::NamedTuple
end

```

1. A parameter type

```julia
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!

---

<div class="post-metadata">

**Author:** ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)\
**Post date:** [January 17, 2021, 10:22pm UTC](https://discourse.julialang.org/t/parameters-of-the-model-free-fixed-constrained/53501/2 "2021-01-17T22:22:58Z")

</div>

I’d probably do the first approach but use

```julia
struct Parameters{R,S,T} where {R,S,T}
    free::R
    fixed::S
    constrained::T
end

```

---

<div class="post-metadata">

**Author:** ![misha\_mikhasenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/misha_mikhasenko/32/5060_2.png) [@misha\_mikhasenko](https://discourse.julialang.org/u/misha_mikhasenko)\
**Post date:** [January 18, 2021, 9:22pm UTC](https://discourse.julialang.org/t/parameters-of-the-model-free-fixed-constrained/53501/3 "2021-01-18T21:22:51Z")

</div>

yes, good point since NamedTuples is parametric.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 19, 2021, 11:57am UTC](https://discourse.julialang.org/t/parameters-of-the-model-free-fixed-constrained/53501/4 "2021-01-19T11:57:26Z")

</div>

> [@misha\_mikhasenko](#):
>
> Any thoughts on what the better way is?

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