@@ -102,17 +102,19 @@ std::vector<double> initialize(Model& model, const InitContext& init, RNG& rng,
102102 model.transform_inits (context, disc_vector, unconstrained, &msg);
103103 }
104104 } catch (std::domain_error& e) {
105- if (msg.str ().length () > 0 )
105+ if (msg.str ().length () > 0 ) {
106106 logger.info (msg);
107+ }
107108 logger.warn (" Rejecting initial value:" );
108109 logger.warn (
109110 " Error evaluating the log probability"
110111 " at the initial value." );
111112 logger.warn (e.what ());
112113 continue ;
113114 } catch (std::exception& e) {
114- if (msg.str ().length () > 0 )
115+ if (msg.str ().length () > 0 ) {
115116 logger.info (msg);
117+ }
116118 logger.error (
117119 " Unrecoverable error evaluating the log probability"
118120 " at the initial value." );
@@ -127,8 +129,9 @@ std::vector<double> initialize(Model& model, const InitContext& init, RNG& rng,
127129 // the parameters.
128130 log_prob = model.template log_prob <false , Jacobian>(unconstrained,
129131 disc_vector, &msg);
130- if (msg.str ().length () > 0 )
132+ if (msg.str ().length () > 0 ) {
131133 logger.info (msg);
134+ }
132135 } catch (std::domain_error& e) {
133136 if (msg.str ().length () > 0 )
134137 logger.info (msg);
@@ -139,8 +142,9 @@ std::vector<double> initialize(Model& model, const InitContext& init, RNG& rng,
139142 logger.warn (e.what ());
140143 continue ;
141144 } catch (std::exception& e) {
142- if (msg.str ().length () > 0 )
145+ if (msg.str ().length () > 0 ) {
143146 logger.info (msg);
147+ }
144148 logger.error (
145149 " Unrecoverable error evaluating the log probability"
146150 " at the initial value." );
@@ -165,8 +169,9 @@ std::vector<double> initialize(Model& model, const InitContext& init, RNG& rng,
165169 log_prob = stan::model::log_prob_grad<true , Jacobian>(
166170 model, unconstrained, disc_vector, gradient, &log_prob_msg);
167171 } catch (const std::exception& e) {
168- if (log_prob_msg.str ().length () > 0 )
172+ if (log_prob_msg.str ().length () > 0 ) {
169173 logger.info (log_prob_msg);
174+ }
170175 logger.error (e.what ());
171176 throw ;
172177 }
@@ -210,8 +215,36 @@ std::vector<double> initialize(Model& model, const InitContext& init, RNG& rng,
210215 return unconstrained;
211216 }
212217 }
213-
214- if (!is_initialized_with_zero) {
218+ if (is_fully_initialized) {
219+ logger.info (" " );
220+ logger.error (" User-specified initialization failed." );
221+ logger.error (
222+ " Try specifying new initial values,"
223+ " using partially specialized initialization,"
224+ " reducing the range of constrained values,"
225+ " or reparameterizing the model." );
226+ } else if (any_initialized) {
227+ logger.info (" " );
228+ std::stringstream msg;
229+ msg << " Partial user-specified initialization failed. "
230+ " Initialization of non user specified parameters "
231+ " between (-"
232+ << init_radius << " , " << init_radius << " ) failed after"
233+ << " " << MAX_INIT_TRIES << " attempts. " ;
234+ logger.error (msg);
235+ logger.error (
236+ " Try specifying full initial values,"
237+ " reducing the range of constrained values,"
238+ " or reparameterizing the model." );
239+ } else if (is_initialized_with_zero) {
240+ logger.info (" " );
241+ logger.error (" Initial values of 0 failed to initialize." );
242+ logger.error (
243+ " Try specifying new initial values,"
244+ " using partially specialized initialization,"
245+ " reducing the range of constrained values,"
246+ " or reparameterizing the model." );
247+ } else {
215248 logger.info (" " );
216249 std::stringstream msg;
217250 msg << " Initialization between (-" << init_radius << " , " << init_radius
0 commit comments