Esempio n. 1
0
 void Vector::Print(const Journalist& jnlst,
                    EJournalLevel level,
                    EJournalCategory category,
                    const std::string& name,
                    Index indent,
                    const std::string& prefix) const
 {
   if (jnlst.ProduceOutput(level, category)) {
     PrintImpl(jnlst, level, category, name, indent, prefix);
   }
 }
Esempio n. 2
0
 void SumSymMatrix::PrintImpl(const Journalist& jnlst,
                              EJournalLevel level,
                              EJournalCategory category,
                              const std::string& name,
                              Index indent,
                              const std::string& prefix) const
 {
   jnlst.Printf(level, category, "\n");
   jnlst.PrintfIndented(level, category, indent,
                        "%sSumSymMatrix \"%s\" of dimension %d with %d terms:\n",
                        prefix.c_str(), name.c_str(), Dim(), NTerms());
   for (Index iterm=0; iterm<NTerms(); iterm++) {
     jnlst.PrintfIndented(level, category, indent,
                          "%sTerm %d with factor %23.16e and the following matrix:\n",
                          prefix.c_str(), iterm, factors_[iterm]);
     char buffer[256];
     sprintf(buffer, "Term: %d", iterm);
     std::string name = buffer;
     matrices_[iterm]->Print(&jnlst, level, category, name, indent+1, prefix);
   }
 }
 void SymScaledMatrix::PrintImpl(const Journalist& jnlst,
                                 EJournalLevel level,
                                 EJournalCategory category,
                                 const std::string& name,
                                 Index indent,
                                 const std::string& prefix) const
 {
   jnlst.Printf(level, category, "\n");
   jnlst.PrintfIndented(level, category, indent,
                        "%sSymScaledMatrix \"%s\" of dimension %d x %d:\n",
                        prefix.c_str(), name.c_str(), NRows(), NCols());
   owner_space_->RowColScaling()->Print(&jnlst, level, category,
                                        name+"_row_col_scaling",
                                        indent+1, prefix);
   if (IsValid(matrix_)) {
     matrix_->Print(&jnlst, level, category, name+"_unscaled_matrix",
                    indent+1, prefix);
   }
   else {
     jnlst.PrintfIndented(level, category, indent,
                          "%sunscaled matrix is NULL\n", prefix.c_str());
   }
 }
Esempio n. 4
0
 void SymTMatrix::PrintImpl(const Journalist& jnlst,
                            EJournalLevel level,
                            EJournalCategory category,
                            const std::string& name,
                            Index indent,
                            const std::string& prefix) const
 {
   jnlst.Printf(level, category, "\n");
   jnlst.PrintfIndented(level, category, indent,
                        "%sSymTMatrix \"%s\" with %d nonzero elements:\n",
                        prefix.c_str(), name.c_str(), Nonzeros());
   if (initialized_) {
     for (Index i=0; i<Nonzeros(); i++) {
       jnlst.PrintfIndented(level, category, indent,
                            "%s%s[%5d,%5d]=%23.16e  (%d)\n",
                            prefix.c_str(), name.c_str(), Irows()[i],
                            Jcols()[i], values_[i], i);
     }
   }
   else {
     jnlst.PrintfIndented(level, category, indent,
                          "%sUninitialized!\n", prefix.c_str());
   }
 }
  void IndexPCalculator::PrintImpl(const Journalist& jnlst,
				   EJournalLevel level,
				   EJournalCategory category,
				   const std::string& name,
				   Index indent,
				   const std::string& prefix) const
  {
    DBG_START_METH("IndexPCalculator::PrintImpl", dbg_verbosity);

    const Number* col_val;
    jnlst.PrintfIndented(level, category, indent,
                         "%sIndexPCalculator \"%s\" with %d rows and %d columns:\n",
                         prefix.c_str(), name.c_str(), nrows_, ncols_ );
    Index col_counter = 0;
    for (std::map< Index, SmartPtr<PColumn> >::const_iterator j=cols_.begin(); j!=cols_.end(); ++j) {
      col_val = j->second->Values();
      for (Index i=0; i<nrows_; ++i) {
	jnlst.PrintfIndented(level, category, indent,
			     "%s%s[%5d,%5d]=%23.16e\n",
			     prefix.c_str(), name.c_str(), i, col_counter, col_val[i]);
      }
      col_counter++;
    }
  }
Esempio n. 6
0
 void Filter::Print(const Journalist& jnlst)
 {
   DBG_START_METH("FilterLineSearch::Filter::Print", dbg_verbosity);
   jnlst.Printf(J_DETAILED, J_LINE_SEARCH,
                "The current filter has %d entries.\n", filter_list_.size());
   if (!jnlst.ProduceOutput(J_VECTOR, J_LINE_SEARCH)) {
     return;
   }
   std::list<FilterEntry*>::iterator iter;
   Index count = 0;
   for (iter = filter_list_.begin(); iter != filter_list_.end();
        iter++) {
     if (count % 10 == 0) {
       jnlst.Printf(J_VECTOR, J_LINE_SEARCH,
                    "                phi                    theta            iter\n");
     }
     count++;
     jnlst.Printf(J_VECTOR, J_LINE_SEARCH, "%5d ", count);
     for (Index i=0; i<dim_; i++) {
       jnlst.Printf(J_VECTOR, J_LINE_SEARCH, "%23.16e ", (*iter)->val(i));
     }
     jnlst.Printf(J_VECTOR, J_LINE_SEARCH, "%5d\n",(*iter)->iter());
   }
 }
Esempio n. 7
0
  void
  TimingStatistics::PrintAllTimingStatistics(
    Journalist& jnlst,
    EJournalLevel level,
    EJournalCategory category) const
  {
    if (!jnlst.ProduceOutput(level, category))
      return;

    jnlst.Printf(level, category,
                 "OverallAlgorithm....................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 OverallAlgorithm_.TotalCpuTime(),
                 OverallAlgorithm_.TotalSysTime(),
                 OverallAlgorithm_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " PrintProblemStatistics.............: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 PrintProblemStatistics_.TotalCpuTime(),
                 PrintProblemStatistics_.TotalSysTime(),
                 PrintProblemStatistics_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " InitializeIterates.................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 InitializeIterates_.TotalCpuTime(),
                 InitializeIterates_.TotalSysTime(),
                 InitializeIterates_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " UpdateHessian......................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 UpdateHessian_.TotalCpuTime(),
                 UpdateHessian_.TotalSysTime(),
                 UpdateHessian_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " OutputIteration....................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 OutputIteration_.TotalCpuTime(),
                 OutputIteration_.TotalSysTime(),
                 OutputIteration_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " UpdateBarrierParameter.............: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 UpdateBarrierParameter_.TotalCpuTime(),
                 UpdateBarrierParameter_.TotalSysTime(),
                 UpdateBarrierParameter_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " ComputeSearchDirection.............: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 ComputeSearchDirection_.TotalCpuTime(),
                 ComputeSearchDirection_.TotalSysTime(),
                 ComputeSearchDirection_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " ComputeAcceptableTrialPoint........: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 ComputeAcceptableTrialPoint_.TotalCpuTime(),
                 ComputeAcceptableTrialPoint_.TotalSysTime(),
                 ComputeAcceptableTrialPoint_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " AcceptTrialPoint...................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 AcceptTrialPoint_.TotalCpuTime(),
                 AcceptTrialPoint_.TotalSysTime(),
                 AcceptTrialPoint_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " CheckConvergence...................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 CheckConvergence_.TotalCpuTime(),
                 CheckConvergence_.TotalSysTime(),
                 CheckConvergence_.TotalWallclockTime());

    jnlst.Printf(level, category,
                 "PDSystemSolverTotal.................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 PDSystemSolverTotal_.TotalCpuTime(),
                 PDSystemSolverTotal_.TotalSysTime(),
                 PDSystemSolverTotal_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " PDSystemSolverSolveOnce............: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 PDSystemSolverSolveOnce_.TotalCpuTime(),
                 PDSystemSolverSolveOnce_.TotalSysTime(),
                 PDSystemSolverSolveOnce_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " ComputeResiduals...................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 ComputeResiduals_.TotalCpuTime(),
                 ComputeResiduals_.TotalSysTime(),
                 ComputeResiduals_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " StdAugSystemSolverMultiSolve.......: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 StdAugSystemSolverMultiSolve_.TotalCpuTime(),
                 StdAugSystemSolverMultiSolve_.TotalSysTime(),
                 StdAugSystemSolverMultiSolve_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " LinearSystemScaling................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 LinearSystemScaling_.TotalCpuTime(),
                 LinearSystemScaling_.TotalSysTime(),
                 LinearSystemScaling_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " LinearSystemSymbolicFactorization..: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 LinearSystemSymbolicFactorization_.TotalCpuTime(),
                 LinearSystemSymbolicFactorization_.TotalSysTime(),
                 LinearSystemSymbolicFactorization_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " LinearSystemFactorization..........: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 LinearSystemFactorization_.TotalCpuTime(),
                 LinearSystemFactorization_.TotalSysTime(),
                 LinearSystemFactorization_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " LinearSystemBackSolve..............: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 LinearSystemBackSolve_.TotalCpuTime(),
                 LinearSystemBackSolve_.TotalSysTime(),
                 LinearSystemBackSolve_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 " LinearSystemStructureConverter.....: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 LinearSystemStructureConverter_.TotalCpuTime(),
                 LinearSystemStructureConverter_.TotalSysTime(),
                 LinearSystemStructureConverter_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 "  LinearSystemStructureConverterInit: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 LinearSystemStructureConverterInit_.TotalCpuTime(),
                 LinearSystemStructureConverterInit_.TotalSysTime(),
                 LinearSystemStructureConverterInit_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 "QualityFunctionSearch...............: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 QualityFunctionSearch_.TotalCpuTime(),
                 QualityFunctionSearch_.TotalSysTime(),
                 QualityFunctionSearch_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 "TryCorrector........................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 TryCorrector_.TotalCpuTime(),
                 TryCorrector_.TotalSysTime(),
                 TryCorrector_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 "Task1...............................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 Task1_.TotalCpuTime(),
                 Task1_.TotalSysTime(),
                 Task1_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 "Task2...............................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 Task2_.TotalCpuTime(),
                 Task2_.TotalSysTime(),
                 Task2_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 "Task3...............................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 Task3_.TotalCpuTime(),
                 Task3_.TotalSysTime(),
                 Task3_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 "Task4...............................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 Task4_.TotalCpuTime(),
                 Task4_.TotalSysTime(),
                 Task4_.TotalWallclockTime());
    jnlst.Printf(level, category,
                 "Task5...............................: %10.3f (sys: %10.3f wall: %10.3f)\n",
                 Task5_.TotalCpuTime(),
                 Task5_.TotalSysTime(),
                 Task5_.TotalWallclockTime());
  }
Esempio n. 8
0
  bool OptionsList::ReadFromStream(const Journalist& jnlst,
                                   std::istream& is)
  {
    jnlst.Printf(J_DETAILED, J_MAIN, "Start reading options from stream.\n");

    while (true) {
      std::string tag;
      std::string value;

      if (!readnexttoken(is, tag)) {
        // That's it - end of file reached.
        jnlst.Printf(J_DETAILED, J_MAIN,
                     "Finished reading options from file.\n");
        return true;
      }

      if (!readnexttoken(is, value)) {
        // Can't read value for a given tag
        jnlst.Printf(J_ERROR, J_MAIN,
                     "Error reading value for tag %s from file.\n",
                     tag.c_str());
        return false;
      }

      // Now add the value for the options list
      jnlst.Printf(J_DETAILED, J_MAIN,
                   "Adding option \"%s\" with value \"%s\" to OptionsList.\n",
                   tag.c_str(), value.c_str());

      if (IsValid(reg_options_)) {
        SmartPtr<const RegisteredOption> option = reg_options_->GetOption(tag);
        if (IsNull(option)) {
          std::string msg = "Read Option: ";
          msg += tag;
          msg += ". It is not a valid option. Check the list of available options.";
          THROW_EXCEPTION(OPTION_INVALID, msg);
        }

        if (option->Type() == OT_String) {
          bool result = SetStringValue(tag, value, false);
          ASSERT_EXCEPTION(result, OPTION_INVALID,
                           "Error setting string value read from option file.");
        }
        else if (option->Type() == OT_Number) {
          char* p_end;
          Number retval = strtod(value.c_str(), &p_end);
          if (*p_end!='\0' && !isspace(*p_end)) {
            std::string msg = "Option \"" + tag +
                              "\": Double value expected, but non-numeric option value \"" +
                              value + "\" found.\n";
            THROW_EXCEPTION(OPTION_INVALID, msg);
          }
          bool result = SetNumericValue(tag, retval, false);
          ASSERT_EXCEPTION(result, OPTION_INVALID,
                           "Error setting numeric value read from file.");
        }
        else if (option->Type() == OT_Integer) {
          char* p_end;
          Index retval = strtol(value.c_str(), &p_end, 10);
          if (*p_end!='\0' && !isspace(*p_end)) {
            std::string msg = "Option \"" + tag +
                              "\": Integer value expected, but non-integer option value \"" +
                              value + "\" found.\n";
            if (IsValid(jnlst_)) {
              option->OutputDescription(*jnlst_);
            }
            THROW_EXCEPTION(OPTION_INVALID, msg);
          }
          bool result = SetIntegerValue(tag, retval, false);
          ASSERT_EXCEPTION(result, OPTION_INVALID,
                           "Error setting integer value read from option file.");
        }
        else {
          DBG_ASSERT(false && "Option Type: Unknown");
        }
      }
      else {
        bool result = SetStringValue(tag, value, false);
        ASSERT_EXCEPTION(result, OPTION_INVALID,
                         "Error setting value read from option file.");
      }
    }
  }
Esempio n. 9
0
  bool OptionsList::ReadFromStream(const Journalist& jnlst,
                                   std::istream& is)
  {
    jnlst.Printf(J_DETAILED, J_MAIN, "Start reading options from stream.\n");

    while (true) {
      std::string tag;
      std::string value;

      if (!readnexttoken(is, tag)) {
        // That's it - end of file reached.
        jnlst.Printf(J_DETAILED, J_MAIN,
                     "Finished reading options from file.\n");
        return true;
      }

      if (!readnexttoken(is, value)) {
        // Can't read value for a given tag
        jnlst.Printf(J_ERROR, J_MAIN,
                     "Error reading value for tag %s from file.\n",
                     tag.c_str());
        return false;
      }

      // Now add the value for the options list
      jnlst.Printf(J_DETAILED, J_MAIN,
                   "Adding option \"%s\" with value \"%s\" to OptionsList.\n",
                   tag.c_str(), value.c_str());

      if (IsValid(reg_options_)) {
        SmartPtr<const RegisteredOption> option = reg_options_->GetOption(tag);
        if (IsNull(option)) {
          std::string msg = "Read Option: \"";
          msg += tag;
          msg += "\". It is not a valid option. Check the list of available options.";
          THROW_EXCEPTION(OPTION_INVALID, msg);
        }

        if (option->Type() == OT_String) {
          bool result = SetStringValue(tag, value, false);
          ASSERT_EXCEPTION(result, OPTION_INVALID,
                           "Error setting string value read from option file.");
        }
        else if (option->Type() == OT_Number) {
          // Some people like to use 'd' instead of 'e' in floating
          // point numbers.  Therefore, we change a 'd' to an 'e'
          char* buffer = new char[value.length()+1];
          strcpy(buffer, value.c_str());
          for (int i=0; i<(int)value.length(); ++i) {
            if (buffer[i]=='d' || buffer[i]=='D') {
              buffer[i] = 'e';
            }
          }
          char* p_end;
          Number retval = strtod(buffer, &p_end);
          if (*p_end!='\0' && !isspace(*p_end)) {
            delete [] buffer;
            std::string msg = "Option \"" + tag +
                              "\": Double value expected, but non-numeric option value \"" +
                              value + "\" found.\n";
            THROW_EXCEPTION(OPTION_INVALID, msg);
          }
          delete [] buffer;
          bool result = SetNumericValue(tag, retval, false);
          ASSERT_EXCEPTION(result, OPTION_INVALID,
                           "Error setting numeric value read from file.");
        }
        else if (option->Type() == OT_Integer) {
          char* p_end;
          size_t retval = strtol(value.c_str(), &p_end, 10);
          if (*p_end!='\0' && !isspace(*p_end)) {
            std::string msg = "Option \"" + tag +
                              "\": Integer value expected, but non-integer option value \"" +
                              value + "\" found.\n";
            if (IsValid(jnlst_)) {
              option->OutputDescription(*jnlst_);
            }
            THROW_EXCEPTION(OPTION_INVALID, msg);
          }
          bool result = SetIntegerValue(tag, static_cast<Index>(retval), false);
          ASSERT_EXCEPTION(result, OPTION_INVALID,
                           "Error setting integer value read from option file.");
        }
        else {
          DBG_ASSERT(false && "Option Type: Unknown");
        }
      }
      else {
        bool result = SetStringValue(tag, value, false);
        ASSERT_EXCEPTION(result, OPTION_INVALID,
                         "Error setting value read from option file.");
      }
    }
  }