Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stan compiler bug - bad indices on param names for matrix or array parameters #2604

Closed
mitzimorris opened this issue Aug 12, 2018 · 1 comment
Assignees

Comments

@mitzimorris
Copy link
Member

mitzimorris commented Aug 12, 2018

Summary:

Stan compiler generator generates wrong set of indexes for multi-dimensional parameters. Introduced by #2498, refactor of Stan lang necessary to add tuple types to the Stan language.

Description:

generated c++ code contains methods constrained_param_names and unconstrained_param_names which generate the indexed multi-dim parameter names, e.g.
code:

 if (!include_gqs__ && !include_tparams__) return;
        size_t y_k_0_max__ = N_t;
        size_t y_k_1_max__ = 4;
        for (size_t k_1__ = 0; k_1__ < y_k_1_max__; ++k_1__) {
            for (size_t k_0__ = 0; k_0__ < y_k_0_max__; ++k_0__) {
                param_name_stream__.str(std::string());
                param_name_stream__ << "y" << '.' << k_0__ + 1 << '.' << k_1__ + 1;
                param_names__.push_back(param_name_stream__.str());
            }
        }

results in this output:

y.1.1,y.2.1,y.3.1,y.4.1,y.5.1,y.6.1,y.7.1,y.8.1,y.9.1,y.10.1,y.11.1,y.12.1,y.13.1,y.14.1,y.15.1,y.16.1,y.17.1,y.18.1,y.19.1,y.20.1,y.1.2,y.2.2,y.3.2,y.4.2,y.5.2,y.6.2,y.7.2,y.8.2,y.9.2,y.10.2,y.11.2,y.12.2,y.13.2,y.14.2,y.15.2,y.16.2,y.17.2,y.18.2,y.19.2,y.20.2,y.1.3,y.2.3,y.3.3,y.4.3,y.5.3,y.6.3,y.7.3,y.8.3,y.9.3,y.10.3,y.11.3,y.12.3,y.13.3,y.14.3,y.15.3,y.16.3,y.17.3,y.18.3,y.19.3,y.20.3,y.1.4,y.2.4,y.3.4,y.4.4,y.5.4,y.6.4,y.7.4,y.8.4,y.9.4,y.10.4,y.11.4,y.12.4,y.13.4,y.14.4,y.15.4,y.16.4,y.17.4,y.18.4,y.19.4,y.20.4

Reproducible Steps:

see above example, model src/test/test-models/good/stat_comp_benchmark_models/sir.stan

Current Output:

y.1.1,y.2.1,y.3.1,y.4.1,y.1.2,y.2.2,y.3.2,y.4.2,y.1.3,y.2.3,y.3.3,y.4.3,y.1.4,y.2.4,y.3.4,y.4.4,y.1.5,y.2.5,y.3.5,y.4.5,y.1.6,y.2.6,y.3.6,y.4.6,y.1.7,y.2.7,y.3.7,y.4.7,y.1.8,y.2.8,y.3.8,y.4.8,y.1.9,y.2.9,y.3.9,y.4.9,y.1.10,y.2.10,y.3.10,y.4.10,y.1.11,y.2.11,y.3.11,y.4.11,y.1.12,y.2.12,y.3.12,y.4.12,y.1.13,y.2.13,y.3.13,y.4.13,y.1.14,y.2.14,y.3.14,y.4.14,y.1.15,y.2.15,y.3.15,y.4.15,y.1.16,y.2.16,y.3.16,y.4.16,y.1.17,y.2.17,y.3.17,y.4.17,y.1.18,y.2.18,y.3.18,y.4.18,y.1.19,y.2.19,y.3.19,y.4.19,y.1.20,y.2.20,y.3.20,y.4.20

Expected Output:

output above.

also, repo stat_comp_benchmark contains models, data, and expected results.

Additional Information:

Provide any additional information here.

Current Version:

v2.18.0

@mitzimorris
Copy link
Member Author

fixed by PR #2611

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant