Skip to content

Unexpected error when passing a multi-index to a offset or multiply constraint #3330

@WardBrian

Description

@WardBrian

Model and data:

data {
  int<lower=1> n_group;
  int<lower=2> n_a;
  array[n_a] int group_index_for_a;
}
parameters {
  vector<lower=0>[n_group] a_group_mu;
  // can also try offset instead
  vector<multiplier=a_group_mu[group_index_for_a]>[n_a] a_effect;
}
{
  "n_group": 5,
  "n_a": 4,
  "group_index_for_a": [5, 3, 1, 5]
}

When using offset, this prints:

Unrecoverable error evaluating the log probability at the initial value.
Exception: constraint: a_effect (140728813511656, 1) and offset (4, 1) must match in size

(note that the size is essentially random and changes each run!!)

When using multiplier as above, it simply segfaults in Eigen::internal::binary_evaluator<Eigen::CwiseBinaryOp<Eigen::internal::scalar_product_op<double, double>, with the backtrace
suggesting the issue is in write_array (meaning the prim overload of everything)

cc @mike-lawrence

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions