ReFRACtor
solver_iteration_log.cc
Go to the documentation of this file.
1 #include "solver_iteration_log.h"
2 
3 using namespace FullPhysics;
4 using namespace blitz;
5 
7 {
8  // Iteration index 0 is the initial state
9  int iter_index = solver.num_accepted_steps();
10 
11  if (iter_index < 0) {
12  throw Exception("Number of iteration indexes indicated by IterativeSolver is negative");
13  }
14 
15  blitz::Array<std::string, 1> sv_names = sv_obj->state_vector_name();
16 
17  blitz::Array<double, 1> curr_sv(solver.accepted_points().at(iter_index));
18  blitz::Array<double, 1> dx;
19 
20  if (iter_index > 0) {
21  dx.resize(curr_sv.rows());
22  dx = solver.accepted_points().at(iter_index) - solver.accepted_points().at(iter_index - 1);
23  }
24 
25  std::stringstream header_log;
26  header_log << std::endl;
27  if (iter_index > 0) {
28  header_log << "Accepted iteration #" << iter_index << std::endl;
29  } else {
30  header_log << "Initial retrieval state" << std::endl;
31  }
32  header_log << "Cost function value: " << solver.cost_at_accepted_points().at(iter_index) << std::endl;
33  Logger::info() << header_log.str();
34 
35  std::stringstream sv_log;
36  sv_log << std::endl
37  << std::setw(SV_PRINT_WIDTH)
38  << "State Vector";
39  if (iter_index > 0) {
40  sv_log << std::setw(SV_PRINT_WIDTH)
41  << "Dx";
42  }
43  sv_log << " Name" << std::endl;
44  for(int sv_idx = 0; sv_idx < curr_sv.rows(); sv_idx++) {
45  sv_log << std::setprecision(SV_PRINT_WIDTH-7) // leave room for -/+, ., exponent and space, etc
46  << std::setw(SV_PRINT_WIDTH)
47  << curr_sv(sv_idx);
48  if (iter_index > 0) {
49  sv_log << std::setw(SV_PRINT_WIDTH)
50  << dx(sv_idx);
51  }
52  sv_log << " "
53  << sv_names(sv_idx)
54  << std::endl;
55  }
56  Logger::info() << sv_log.str();
57 }
static LogHelper info()
Definition: logger.h:109
This is the base of the exception hierarchy for Full Physics code.
Definition: fp_exception.h:16
virtual int num_accepted_steps() const
Returns the number of the accepted steps.
Apply value function to a blitz array.
virtual std::vector< blitz::Array< double, 1 > > accepted_points() const
Returns a vector (std) of accepted points.
void notify_update(const IterativeSolver &solver)
Called when the Observed object is updated.
virtual std::vector< double > cost_at_accepted_points() const
Returns a vector (std) of cost function values at accepted points.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
The base class for all iterative optimizers.

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:10