# Optimization and generated parameters

**URL:** <https://discourse.mc-stan.org/t/optimization-and-generated-parameters/4407>\
**Category:** Developers\
**Created:** [June 3, 2018, 12:20pm UTC](https://discourse.mc-stan.org/t/optimization-and-generated-parameters/4407 "2018-06-03T12:20:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)\
**Post date:** [June 3, 2018, 12:20pm UTC](https://discourse.mc-stan.org/t/optimization-and-generated-parameters/4407/1 "2018-06-03T12:20:21Z")

</div>

I just noticed today that the generated parameters block is used during optimization – perhaps I’m missing something, but this seems a) more costly (relatively) than in the HMC case with many steps per single generated parameters computation, b) not at all useful.

---

<div class="post-metadata">

**Author:** ![sakrejda](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/sakrejda/32/845_2.png) [@sakrejda](https://discourse.mc-stan.org/u/sakrejda)\
**Post date:** [June 3, 2018, 1:09pm UTC](https://discourse.mc-stan.org/t/optimization-and-generated-parameters/4407/2 "2018-06-03T13:09:23Z")

</div>

It’s probably something that could be optional once the output handling is more flexible. Do you know what would have to change?

---

<div class="post-metadata">

**Author:** ![Charles\_Driver](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/charles_driver/32/6524_2.png) [@Charles\_Driver](https://discourse.mc-stan.org/u/Charles_Driver)\
**Post date:** [June 3, 2018, 1:18pm UTC](https://discourse.mc-stan.org/t/optimization-and-generated-parameters/4407/3 "2018-06-03T13:18:32Z")

</div>

I’m not so familiar with the inner workings of Stan, but naively, I would have expected that during optimization, only the gradient and lp are needed (neither of which should compute generated quantities), then the quantities can be generated once, at convergence.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [June 27, 2018, 4:55am UTC](https://discourse.mc-stan.org/t/optimization-and-generated-parameters/4407/4 "2018-06-27T04:55:42Z")

</div>

> [@Charles\_Driver](#):
>
> then the quantities can be generated once, at convergence.

That’s the goal for when we get all of our I/O in order. Right now, I think it’s too much of a challenge dealing with non-rectangular data structures that result from missing generated quantities in warmup iterations.
