void CompoundVector::ElementWiseMinImpl(const Vector& x)
 {
   DBG_START_METH("CompoundVector::ElementWiseMinImpl", dbg_verbosity);
   DBG_ASSERT(vectors_valid_);
   const CompoundVector* comp_x = static_cast<const CompoundVector*>(&x);
   DBG_ASSERT(dynamic_cast<const CompoundVector*>(&x));
   DBG_ASSERT(NComps() == comp_x->NComps());
   for (Index i=0; i<NComps(); i++) {
     Comp(i)->ElementWiseMin(*comp_x->GetComp(i));
   }
 }
Exemplo n.º 2
0
 bool DenseGenSchurDriver::SchurFactorize()
 {
   DBG_START_METH("DenseGenSchurDriver::SchurFactorize", dbg_verbosity);
   /* This function is the very same as the one in DenseGenSchurDriver */
   bool retval;
   if (IsValid(S_)) {
     retval = S_->ComputeLUFactorInPlace();
     return retval;
   }
   return true;
 }
 Number CompoundVector::Nrm2Impl() const
 {
   DBG_START_METH("CompoundVector::Nrm2Impl", dbg_verbosity);
   DBG_ASSERT(vectors_valid_);
   Number sum=0.;
   for (Index i=0; i<NComps(); i++) {
     Number nrm2 = ConstComp(i)->Nrm2();
     sum += nrm2*nrm2;
   }
   return sqrt(sum);
 }
Exemplo n.º 4
0
  bool CachedResults<T>::GetCachedResult1Dep(T& retResult, const TaggedObject* dependent1)
  {
#ifdef IP_DEBUG_CACHE
    DBG_START_METH("CachedResults<T>::GetCachedResult1Dep", dbg_verbosity);
#endif

    std::vector<const TaggedObject*> dependents(1);
    dependents[0] = dependent1;

    return GetCachedResult(retResult, dependents);
  }
Exemplo n.º 5
0
 SmartPtr<const Vector> StandardScalingBase::unapply_vector_scaling_x(
   const SmartPtr<const Vector>& v)
 {
   DBG_START_METH("NLPScalingObject::unapply_vector_scaling_x", dbg_verbosity);
   if (IsValid(dx_)) {
     return ConstPtr(unapply_vector_scaling_x_NonConst(v));
   }
   else {
     return v;
   }
 }
Exemplo n.º 6
0
 SmartPtr<Vector> NLPScalingObject::unapply_grad_obj_scaling_NonConst(
   const SmartPtr<const Vector>& v)
 {
   DBG_START_METH("NLPScalingObject::unapply_grad_obj_scaling_NonConst", dbg_verbosity);
   SmartPtr<Vector> unscaled_v = apply_vector_scaling_x_NonConst(v);
   Number df = unapply_obj_scaling(1.);
   if (df != 1.) {
     unscaled_v->Scal(df);
   }
   return unscaled_v;
 }
Exemplo n.º 7
0
  inline
  void Subject::Notify(Observer::NotifyType notify_type) const
  {
#ifdef IP_DEBUG_OBSERVER
    DBG_START_METH("Subject::Notify", dbg_verbosity);
#endif

    std::vector<Observer*>::iterator iter;
    for (iter = observers_.begin(); iter != observers_.end(); iter++) {
      (*iter)->ProcessNotification(notify_type, this);
    }
  }
Exemplo n.º 8
0
  inline
  Subject::~Subject()
  {
#ifdef IP_DEBUG_OBSERVER
    DBG_START_METH("Subject::~Subject", dbg_verbosity);
#endif

    std::vector<Observer*>::iterator iter;
    for (iter = observers_.begin(); iter != observers_.end(); iter++) {
      (*iter)->ProcessNotification(Observer::NT_BeingDestroyed, this);
    }
  }
Exemplo n.º 9
0
  void DependentResult<T>::RecieveNotification(NotifyType notify_type, const Subject* subject)
  {
#ifdef IP_DEBUG_CACHE
    DBG_START_METH("DependentResult<T>::RecieveNotification", dbg_verbosity);
#endif

    if (notify_type == NT_Changed || notify_type==NT_BeingDestroyed) {
      stale_ = true;
      // technically, I could unregister the notifications here, but they
      // aren't really hurting anything
    }
  }
Exemplo n.º 10
0
bool LowRankAugSystemSolver::AugmentedSystemRequiresChange(
   const SymMatrix* W,
   double           W_factor,
   const Vector*    D_x,
   double           delta_x,
   const Vector*    D_s,
   double           delta_s,
   const Matrix&    J_c,
   const Vector*    D_c,
   double           delta_c,
   const Matrix&    J_d,
   const Vector*    D_d,
   double           delta_d
   )
{
   DBG_START_METH("LowRankAugSystemSolver::AugmentedSystemRequiresChange",
      dbg_verbosity);

#if COIN_IPOPT_VERBOSITY > 0

   bool Wtest = (W && W->GetTag() != w_tag_);
   bool iWtest = (!W && w_tag_ != 0);
   bool wfactor_test = (W_factor != w_factor_);
   bool D_xtest = (D_x && D_x->GetTag() != d_x_tag_);
   bool iD_xtest = (!D_x && d_x_tag_ != 0);
   bool delta_xtest = (delta_x != delta_x_);
   bool D_stest = (D_s && D_s->GetTag() != d_s_tag_);
   bool iD_stest = (!D_s && d_s_tag_ != 0);
   bool delta_stest = (delta_s != delta_s_);
   bool J_ctest = (J_c.GetTag() != j_c_tag_);
   bool D_ctest = (D_c && D_c->GetTag() != d_c_tag_);
   bool iD_ctest = (!D_c && d_c_tag_ != 0);
   bool delta_ctest = (delta_c != delta_c_);
   bool J_dtest = (J_d.GetTag() != j_d_tag_);
   bool D_dtest = (D_d && D_d->GetTag() != d_d_tag_);
   bool iD_dtest = (!D_d && d_d_tag_ != 0);
   bool delta_dtest = (delta_d != delta_d_);
#endif

   DBG_PRINT((2, "Wtest = %d\n", Wtest)); DBG_PRINT((2, "iWtest = %d\n", iWtest)); DBG_PRINT((2, "wfactor_test = %d\n", wfactor_test)); DBG_PRINT((2, "D_xtest = %d\n", D_xtest)); DBG_PRINT((2, "iD_xtest = %d\n", iD_xtest)); DBG_PRINT((2, "delta_xtest = %d\n", delta_xtest)); DBG_PRINT((2, "D_stest = %d\n", D_stest)); DBG_PRINT((2, "iD_stest = %d\n", iD_stest)); DBG_PRINT((2, "delta_stest = %d\n", delta_stest)); DBG_PRINT((2, "J_ctest = %d\n", J_ctest)); DBG_PRINT((2, "D_ctest = %d\n", D_ctest)); DBG_PRINT((2, "iD_ctest = %d\n", iD_ctest)); DBG_PRINT((2, "delta_ctest = %d\n", delta_ctest)); DBG_PRINT((2, "J_dtest = %d\n", J_dtest)); DBG_PRINT((2, "D_dtest = %d\n", D_dtest)); DBG_PRINT((2, "iD_dtest = %d\n", iD_dtest)); DBG_PRINT((2, "delta_dtest = %d\n", delta_dtest));

   if( (W && W->GetTag() != w_tag_) || (!W && w_tag_ != 0) || (W_factor != w_factor_)
      || (D_x && D_x->GetTag() != d_x_tag_) || (!D_x && d_x_tag_ != 0) || (delta_x != delta_x_)
      || (D_s && D_s->GetTag() != d_s_tag_) || (!D_s && d_s_tag_ != 0) || (delta_s != delta_s_)
      || (J_c.GetTag() != j_c_tag_) || (D_c && D_c->GetTag() != d_c_tag_) || (!D_c && d_c_tag_ != 0)
      || (delta_c != delta_c_) || (J_d.GetTag() != j_d_tag_) || (D_d && D_d->GetTag() != d_d_tag_)
      || (!D_d && d_d_tag_ != 0) || (delta_d != delta_d_) )
   {
      return true;
   }

   return false;
}
Exemplo n.º 11
0
  MumpsSolverInterface::~MumpsSolverInterface()
  {
    DBG_START_METH("MumpsSolverInterface::~MumpsSolverInterface()",
                   dbg_verbosity);

    DMUMPS_STRUC_C* mumps_ = (DMUMPS_STRUC_C*)mumps_ptr_;
    mumps_->job = -2; //terminate mumps
    dmumps_c(mumps_);
    MPI_Finalize();
    delete [] mumps_->a;
    delete mumps_;
  }
Exemplo n.º 12
0
 SmartPtr<const Vector> StandardScalingBase::unapply_vector_scaling_d(
   const SmartPtr<const Vector>& v)
 {
   DBG_START_METH("NLPScalingObject::unapply_vector_scaling_d", dbg_verbosity);
   if (IsValid(scaled_jac_d_space_) &&
       IsValid(scaled_jac_d_space_->RowScaling())) {
     return ConstPtr(unapply_vector_scaling_d_NonConst(v));
   }
   else {
     return v;
   }
 }
Exemplo n.º 13
0
  bool CGPenaltyLSAcceptor::RestoreBestPoint()
  {
    DBG_START_METH("CGPenaltyLSAcceptor::RestoreBestPoint",
                   dbg_verbosity);

    if (!IsValid(best_iterate_)) {
      return false;
    }
    SmartPtr<IteratesVector> prev_iterate = best_iterate_->MakeNewContainer();
    IpData().set_trial(prev_iterate);
    return true;
  }
  IterativeWsmpSolverInterface::~IterativeWsmpSolverInterface()
  {
    DBG_START_METH("IterativeWsmpSolverInterface::~IterativeWsmpSolverInterface()",
                   dbg_verbosity);

    // Clear WSMP's memory
    F77_FUNC_(wsmp_clear,WSMP_CLEAR)();

    delete[] IPARM_;
    delete[] DPARM_;
    delete[] a_;
  }
Exemplo n.º 15
0
Ma57TSolverInterface::~Ma57TSolverInterface()
{
    DBG_START_METH("Ma57TSolverInterface::~Ma57TSolverInterface()",
                   dbg_verbosity);
    delete [] a_;

    delete [] wd_fact_;
    delete [] wd_ifact_;

    delete [] wd_iwork_;
    delete [] wd_keep_;
}
  ESymSolverStatus
  IterativeWsmpSolverInterface::SymbolicFactorization(
    const Index* ia,
    const Index* ja)
  {
    DBG_START_METH("IterativeWsmpSolverInterface::SymbolicFactorization",
                   dbg_verbosity);

    // This is postponed until the first factorization call, since
    // then the values in the matrix are known
    return SYMSOLVER_SUCCESS;
  }
Exemplo n.º 17
0
 SensAlgorithm::~SensAlgorithm()
 {
   DBG_START_METH("SensAlgorithm::~SensAlgorithm", dbg_verbosity);
   if (NULL != DirectionalD_X_) delete [] DirectionalD_X_ ;
   if (NULL != DirectionalD_L_) delete [] DirectionalD_L_ ;
   if (NULL != DirectionalD_Z_U_) delete [] DirectionalD_Z_U_ ;
   if (NULL != DirectionalD_Z_L_) delete [] DirectionalD_Z_L_ ;
   if (NULL != SensitivityM_X_) delete [] SensitivityM_X_ ;
   if (NULL != SensitivityM_L_) delete [] SensitivityM_L_ ;
   if (NULL != SensitivityM_Z_U_) delete [] SensitivityM_Z_U_ ;
   if (NULL != SensitivityM_Z_L_) delete [] SensitivityM_Z_L_ ;
 }
Exemplo n.º 18
0
 SmartPtr<const Vector> NLPScalingObject::apply_vector_scaling_d_LU(
   const Matrix& Pd_LU,
   const SmartPtr<const Vector>& lu,
   const VectorSpace& d_space)
 {
   DBG_START_METH("NLPScalingObject::apply_vector_scaling_d_LU", dbg_verbosity);
   if (have_d_scaling()) {
     return ConstPtr(apply_vector_scaling_d_LU_NonConst(Pd_LU, lu, d_space));
   }
   else {
     return lu;
   }
 }
Exemplo n.º 19
0
 Number PiecewisePenalty::BiggestBarr()
 {
   DBG_START_METH("PiecewisePenalty::BiggestBarr", dbg_verbosity);
   DBG_ASSERT(!IsPiecewisePenaltyListEmpty());
   Number value = -1e20;
   if (PiecewisePenalty_list_.size() > 0) {
     std::vector<PiecewisePenEntry>::iterator iter;
     iter = PiecewisePenalty_list_.end();
     iter--;
     value = iter->barrier_obj;
   }
   return value;
 }
 Number CompoundVector::MinImpl() const
 {
   DBG_START_METH("CompoundVector::MinImpl", dbg_verbosity);
   DBG_ASSERT(vectors_valid_);
   DBG_ASSERT(NComps() > 0 && Dim() > 0 && "There is no Min of a zero length vector (no reasonable default can be returned)");
   Number min = std::numeric_limits<Number>::max();
   for (Index i=0; i<NComps(); i++) {
     if (ConstComp(i)->Dim() != 0) {
       min = Ipopt::Min(min, ConstComp(i)->Min());
     }
   }
   return min;
 }
  void CompoundVector::AxpyImpl(Number alpha, const Vector &x)
  {
    DBG_START_METH("CompoundVector::AxpyImpl", dbg_verbosity);
    DBG_ASSERT(vectors_valid_);
    const CompoundVector* comp_x = static_cast<const CompoundVector*>(&x);
    DBG_ASSERT(dynamic_cast<const CompoundVector*>(&x));

    DBG_ASSERT(NComps() == comp_x->NComps());
    for (Index i=0; i<NComps(); i++) {
      DBG_ASSERT(Comp(i));
      Comp(i)->Axpy(alpha, *comp_x->GetComp(i));
    }
  }
Exemplo n.º 22
0
  bool TSymDependencyDetector::DetermineDependentRows(
    Index n_rows, Index n_cols, Index n_jac_nz, Number* jac_c_vals,
    Index* jac_c_iRow, Index* jac_c_jCol, std::list<Index>& c_deps)
  {
    DBG_START_METH("TSymDependencyDetector::DetermineDependentRows",
                   dbg_verbosity);

    ESymSolverStatus retval =
      tsym_linear_solver_->DetermineDependentRows(n_rows, n_cols, n_jac_nz,
          jac_c_vals, jac_c_iRow,
          jac_c_jCol, c_deps);

    return (retval == SYMSOLVER_SUCCESS);
  }
Exemplo n.º 23
0
  bool IndexPCalculator::InitializeImpl(const OptionsList& options,
					const std::string& prefix)
  {
    DBG_START_METH("IndexPCalculator::InitializeImpl", dbg_verbosity);

    SmartPtr<const IteratesVector> iv = IpData().curr();
    nrows_ = 0;
    for (Index i=0; i<iv->NComps(); ++i) {
      nrows_+=iv->GetComp(i)->Dim();
    }
    data_A()->Print(Jnlst(),J_VECTOR,J_USER1,"PCalc SchurData");

    return true;
  }
Exemplo n.º 24
0
  WsmpSolverInterface::WsmpSolverInterface()
      :
      a_(NULL),
      negevals_(-1),
      initialized_(false),

      PERM_(NULL),
      INVP_(NULL)
  {
    DBG_START_METH("WsmpSolverInterface::WsmpSolverInterface()",dbg_verbosity);

    IPARM_ = new ipfint[64];
    DPARM_ = new double[64];
  }
 Number CompoundVector::DotImpl(const Vector &x) const
 {
   DBG_START_METH("CompoundVector::DotImpl", dbg_verbosity);
   DBG_ASSERT(vectors_valid_);
   const CompoundVector* comp_x = static_cast<const CompoundVector*>(&x);
   DBG_ASSERT(dynamic_cast<const CompoundVector*>(&x));
   DBG_ASSERT(NComps() == comp_x->NComps());
   Number dot = 0.;
   for (Index i=0; i<NComps(); i++) {
     DBG_ASSERT(ConstComp(i));
     dot += ConstComp(i)->Dot(*comp_x->GetComp(i));
   }
   return dot;
 }
Exemplo n.º 26
0
 SmartPtr<Vector> StandardScalingBase::unapply_vector_scaling_x_NonConst(
   const SmartPtr<const Vector>& v)
 {
   DBG_START_METH("StandardScalingBase::unapply_vector_scaling_x_NonConst",
                  dbg_verbosity);
   SmartPtr<Vector> unscaled_x = v->MakeNewCopy();
   if (IsValid(dx_)) {
     unscaled_x->ElementWiseDivide(*dx_);
   }
   else {
     DBG_PRINT((1, "Creating copy in unapply_vector_scaling_x_NonConst!"));
   }
   return unscaled_x;
 }
Exemplo n.º 27
0
  ESymSolverStatus MumpsSolverInterface::MultiSolve(bool new_matrix,
      const Index* ia,
      const Index* ja,
      Index nrhs,
      double* rhs_vals,
      bool check_NegEVals,
      Index numberOfNegEVals)
  {
    DBG_START_METH("MumpsSolverInterface::MultiSolve", dbg_verbosity);
    DBG_ASSERT(!check_NegEVals || ProvidesInertia());
    DBG_ASSERT(initialized_);
    DBG_ASSERT(((DMUMPS_STRUC_C*)mumps_ptr_)->irn == ia);
    DBG_ASSERT(((DMUMPS_STRUC_C*)mumps_ptr_)->jcn == ja);

    if (pivtol_changed_) {
      DBG_PRINT((1,"Pivot tolerance has changed.\n"));
      pivtol_changed_ = false;
      // If the pivot tolerance has been changed but the matrix is not
      // new, we have to request the values for the matrix again to do
      // the factorization again.
      if (!new_matrix) {
        DBG_PRINT((1,"Ask caller to call again.\n"));
        refactorize_ = true;
        return SYMSOLVER_CALL_AGAIN;
      }
    }

    // check if a factorization has to be done
    DBG_PRINT((1, "new_matrix = %d\n", new_matrix));
    if (new_matrix || refactorize_) {
      ESymSolverStatus retval;
      // Do the symbolic facotrization if it hasn't been done yet
      if (!have_symbolic_factorization_) {
        retval = SymbolicFactorization();
        if (retval != SYMSOLVER_SUCCESS ) {
          return retval;
        }
        have_symbolic_factorization_ = true;
      }
      // perform the factorization
      retval = Factorization(check_NegEVals, numberOfNegEVals);
      if (retval != SYMSOLVER_SUCCESS)  {
        DBG_PRINT((1, "FACTORIZATION FAILED!\n"));
        return retval;  // Matrix singular or error occurred
      }
      refactorize_ = false;
    }
    // do the solve
    return Solve(nrhs, rhs_vals);
  }
Exemplo n.º 28
0
 SmartPtr<const Vector> NLPScalingObject::unapply_grad_obj_scaling(
   const SmartPtr<const Vector>& v)
 {
   DBG_START_METH("NLPScalingObject::unapply_grad_obj_scaling", dbg_verbosity);
   Number df = unapply_obj_scaling(1.);
   if (df != 1.) {
     SmartPtr<Vector> unscaled_v = unapply_grad_obj_scaling_NonConst(v);
     return ConstPtr(unscaled_v);
   }
   else {
     SmartPtr<const Vector> scaled_v = apply_vector_scaling_x(v);
     return scaled_v;
   }
 }
Exemplo n.º 29
0
  void CachedResults<T>::AddCachedResult2Dep(const T& result, const TaggedObject* dependent1,
      const TaggedObject* dependent2)

  {
#ifdef IP_DEBUG_CACHE
    DBG_START_METH("CachedResults<T>::AddCachedResult2dDep", dbg_verbosity);
#endif

    std::vector<const TaggedObject*> dependents(2);
    dependents[0] = dependent1;
    dependents[1] = dependent2;

    AddCachedResult(result, dependents);
  }
Exemplo n.º 30
0
  bool AmplTNLP::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
  {
    DBG_START_METH("AmplTNLP::eval_g", dbg_verbosity);

    DBG_DO(ASL_pfgh* asl = asl_);
    DBG_ASSERT(n == n_var);
    DBG_ASSERT(m == n_con);

    if (!apply_new_x(new_x, n, x)) {
      return false;
    }

    return internal_conval(x, m, g);
  }