@@ -149,6 +149,26 @@ class Report
149149 output << coordinates.n_cols << std::endl;
150150 output << std::endl;
151151
152+ // If we did not take any steps, at least fill what the initial objective
153+ // was.
154+ const bool tookStep = (objectives.size () > 0 );
155+ if (objectives.size () == 0 && evaluateCalls > 0 )
156+ {
157+ objectives.push_back (objective);
158+ timings.push_back (optimizationTimer.toc ());
159+ }
160+ else if (evaluateCalls == 0 )
161+ {
162+ // It's not entirely clear how to compute the objective (since the
163+ // function could implement many different ways of evaluating the
164+ // objective), so issue an error and return.
165+ output << " Objective never computed. Did the optimization fail?"
166+ << std::endl;
167+ PrettyPrintElement (" Time (in seconds):" , 30 );
168+ output << optimizationTimer.toc () << std::endl;
169+ return ;
170+ }
171+
152172 output << " Loss:" << std::endl;
153173 PrettyPrintElement (" Initial" , 30 );
154174 output << objectives[0 ] << std::endl;
@@ -166,7 +186,10 @@ class Report
166186 output << optimizerStream.str ();
167187
168188 PrettyPrintElement (" Iterations:" , 30 );
169- output << objectives.size () << std::endl;
189+ if (tookStep)
190+ output << objectives.size () << std::endl;
191+ else
192+ output << " 0 (No steps taken! Did the optimization fail?)" << std::endl;
170193
171194 if (epochCalls > 0 )
172195 {
@@ -183,7 +206,7 @@ class Report
183206 output << stepsizes.back () << std::endl;
184207 }
185208
186- if (hasGradient)
209+ if (hasGradient && gradientsNorm. size () > 0 )
187210 {
188211 PrettyPrintElement (" Coordinates max. norm:" , 30 );
189212 output << *std::max_element (std::begin (gradientsNorm),
0 commit comments