diff --git a/src/Drivers/PriDec/NlpPriDecEx1.cpp b/src/Drivers/PriDec/NlpPriDecEx1.cpp index 2a99e4500..1f847886b 100644 --- a/src/Drivers/PriDec/NlpPriDecEx1.cpp +++ b/src/Drivers/PriDec/NlpPriDecEx1.cpp @@ -257,7 +257,7 @@ solve_master(hiopVector& x, }; -bool PriDecMasterProblemEx1::eval_f_rterm(size_t idx, const int& n,const double* x, double& rval) +bool PriDecMasterProblemEx1::eval_f_rterm(size_type idx, const int& n,const double* x, double& rval) { rval = 0.; for(int i=0; i(nc_) == n); double* grad_vec = grad.local_data(); diff --git a/src/Drivers/PriDec/NlpPriDecEx1.hpp b/src/Drivers/PriDec/NlpPriDecEx1.hpp index d425560a7..a0d3663f8 100644 --- a/src/Drivers/PriDec/NlpPriDecEx1.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx1.hpp @@ -151,12 +151,12 @@ class PriDecMasterProblemEx1 : public hiopInterfacePriDecProblem /** * This function returns the recourse objective, which is 0.5*(x+Se_i)(x+Se_i). */ - virtual bool eval_f_rterm(size_t idx, const int& n,const double* x, double& rval); + virtual bool eval_f_rterm(size_type idx, const int& n,const double* x, double& rval); /** * This function returns the recourse gradient. */ - virtual bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad); + virtual bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad); /** * This function sets up the approximation of the recourse objective based on the function value and gradient @@ -167,8 +167,8 @@ class PriDecMasterProblemEx1 : public hiopInterfacePriDecProblem virtual bool set_recourse_approx_evaluator(const int n, hiopInterfacePriDecProblem::RecourseApproxEvaluator* evaluator); // Returns the number S of recourse terms. - size_t get_num_rterms() const {return S_;} - size_t get_num_vars() const {return n_;} + size_type get_num_rterms() const {return S_;} + size_type get_num_vars() const {return n_;} // Returns the solution. void get_solution(double* x) const { @@ -177,9 +177,9 @@ class PriDecMasterProblemEx1 : public hiopInterfacePriDecProblem } double get_objective() {return obj_;} private: - size_t n_; - size_t S_; - size_t nc_; + size_type n_; + size_type S_; + size_type nc_; PriDecEx1* my_nlp; double obj_; double* sol_; diff --git a/src/Drivers/PriDec/NlpPriDecEx2.cpp b/src/Drivers/PriDec/NlpPriDecEx2.cpp index 749c1147f..906f943e7 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2.cpp +++ b/src/Drivers/PriDec/NlpPriDecEx2.cpp @@ -10,7 +10,7 @@ using namespace hiop; PriDecMasterProbleEx2:: -PriDecMasterProbleEx2(size_t nx, size_t ny, size_t nS, size_t S) : nx_(nx), ny_(ny),nS_(nS),S_(S) +PriDecMasterProbleEx2(size_type nx, size_type ny, size_type nS, size_type S) : nx_(nx), ny_(ny),nS_(nS),S_(S) { assert(nx==ny); y_ = new double[ny_]; @@ -103,7 +103,7 @@ set_recourse_approx_evaluator(const int n, return true; } -bool PriDecMasterProbleEx2::eval_f_rterm(size_t idx, const int& n, const double* x, double& rval) +bool PriDecMasterProbleEx2::eval_f_rterm(size_type idx, const int& n, const double* x, double& rval) { assert(nx_==n); rval=-1e+20; @@ -173,7 +173,7 @@ bool PriDecMasterProbleEx2::eval_f_rterm(size_t idx, const int& n, const double* }; // returns the gradient computed in eval_f_rterm -bool PriDecMasterProbleEx2::eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad) +bool PriDecMasterProbleEx2::eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad) { assert(nx_==n); double* grad_vec = grad.local_data(); @@ -183,12 +183,12 @@ bool PriDecMasterProbleEx2::eval_grad_rterm(size_t idx, const int& n, double* x, return true; }; -inline size_t PriDecMasterProbleEx2::get_num_rterms() const +inline size_type PriDecMasterProbleEx2::get_num_rterms() const { return S_; } -inline size_t PriDecMasterProbleEx2::get_num_vars() const +inline size_type PriDecMasterProbleEx2::get_num_vars() const { return nx_; } diff --git a/src/Drivers/PriDec/NlpPriDecEx2.hpp b/src/Drivers/PriDec/NlpPriDecEx2.hpp index 3d76e8399..e2e78248c 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2.hpp @@ -67,7 +67,7 @@ using namespace hiop; class PriDecMasterProbleEx2 : public hiop::hiopInterfacePriDecProblem { public: - PriDecMasterProbleEx2(size_t nx, size_t ny, size_t nS, size_t S); + PriDecMasterProbleEx2(size_type nx, size_type ny, size_type nS, size_type S); virtual ~PriDecMasterProbleEx2(); @@ -86,18 +86,18 @@ class PriDecMasterProbleEx2 : public hiop::hiopInterfacePriDecProblem * n is the number of coupled x, not the entire dimension of x, and might be denoted as nc_ elsewhere. * rval is the return value of the recourse solution function evaluation. */ - bool eval_f_rterm(size_t idx, const int& n, const double* x, double& rval); + bool eval_f_rterm(size_type idx, const int& n, const double* x, double& rval); /** * This function computes the gradient of the recourse solution function w.r.t x. * n is the number of coupled x, not the entire dimension of x, and * grad is the output. */ - bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad); + bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad); - inline size_t get_num_rterms() const; + inline size_type get_num_rterms() const; - inline size_t get_num_vars() const; + inline size_type get_num_vars() const; void get_solution(double* x) const; @@ -105,15 +105,15 @@ class PriDecMasterProbleEx2 : public hiop::hiopInterfacePriDecProblem private: /// dimension of primal variable `x` - size_t nx_; + size_type nx_; /// dimension of the coupled variable, nc_<=nx_ - size_t nc_; + size_type nc_; ///dimension of recourse problem primal variable `y` for each contingency - size_t ny_; + size_type ny_; /// dimension of uncertainty dimension entering the recourse problem - size_t nS_; + size_type nS_; ///number of sample to use, effectively the number of recourse terms - size_t S_; + size_type S_; double* y_; diff --git a/src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp b/src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp index 3f188c184..e2dcc2565 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp +++ b/src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp @@ -5,7 +5,7 @@ using namespace hiop; PriDecMasterProbleEx2Sparse:: -PriDecMasterProbleEx2Sparse(size_t nx, size_t ny, size_t nS, size_t S) : nx_(nx), ny_(ny),nS_(nS),S_(S) +PriDecMasterProbleEx2Sparse(size_type nx, size_type ny, size_type nS, size_type S) : nx_(nx), ny_(ny),nS_(nS),S_(S) { assert(nx==ny); y_ = new double[ny_]; @@ -95,7 +95,7 @@ set_recourse_approx_evaluator(const int n, return true; } -bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const double* x, double& rval) +bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_type idx, const int& n, const double* x, double& rval) { assert(nx_==n); rval=-1e+20; @@ -166,7 +166,7 @@ bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const d }; // returns the gradient computed in eval_f_rterm -bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad) +bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad) { assert(nx_==n); double* grad_vec = grad.local_data(); @@ -176,12 +176,12 @@ bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_t idx, const int& n, doub return true; }; -inline size_t PriDecMasterProbleEx2Sparse::get_num_rterms() const +inline size_type PriDecMasterProbleEx2Sparse::get_num_rterms() const { return S_; } -inline size_t PriDecMasterProbleEx2Sparse::get_num_vars() const +inline size_type PriDecMasterProbleEx2Sparse::get_num_vars() const { return nx_; } diff --git a/src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp b/src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp index d99acc48f..47a44320e 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp @@ -66,7 +66,7 @@ using namespace hiop; class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem { public: - PriDecMasterProbleEx2Sparse(size_t nx, size_t ny, size_t nS, size_t S); + PriDecMasterProbleEx2Sparse(size_type nx, size_type ny, size_type nS, size_type S); virtual ~PriDecMasterProbleEx2Sparse(); @@ -85,18 +85,18 @@ class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem * n is the number of coupled x, not the entire dimension of x, and might be denoted as nc_ elsewhere. * rval is the return value of the recourse solution function evaluation. */ - bool eval_f_rterm(size_t idx, const int& n, const double* x, double& rval); + bool eval_f_rterm(size_type idx, const int& n, const double* x, double& rval); /** * This function computes the gradient of the recourse solution function w.r.t x. * n is the number of coupled x, not the entire dimension of x, and * grad is the output. */ - bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad); + bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad); - inline size_t get_num_rterms() const; + inline size_type get_num_rterms() const; - inline size_t get_num_vars() const; + inline size_type get_num_vars() const; void get_solution(double* x) const; @@ -104,15 +104,15 @@ class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem private: /// dimension of primal variable `x` - size_t nx_; + size_type nx_; /// dimension of the coupled variable, nc_<=nx_ - size_t nc_; + size_type nc_; ///dimension of recourse problem primal variable `y` for each contingency - size_t ny_; + size_type ny_; /// dimension of uncertainty dimension entering the recourse problem - size_t nS_; + size_type nS_; ///number of sample to use, effectively the number of recourse terms - size_t S_; + size_type S_; double* y_; diff --git a/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp b/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp index abcf6c552..eaa43fe91 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp +++ b/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp @@ -22,7 +22,7 @@ using ex9_raja_reduce = hiop::ExecRajaPoliciesBackend:: using namespace hiop; PriDecMasterProbleEx2Sparse:: -PriDecMasterProbleEx2Sparse(size_t nx, size_t ny, size_t nS, size_t S, std::string mem_space) +PriDecMasterProbleEx2Sparse(size_type nx, size_type ny, size_type nS, size_type S, std::string mem_space) : nx_(nx), ny_(ny), nS_(nS), @@ -118,7 +118,7 @@ set_recourse_approx_evaluator(const int n, } // all the memory management is done through umpire in the PriDecRecourseProbleEx2Sparse class -bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const double* x, double& rval) +bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_type idx, const int& n, const double* x, double& rval) { assert(nx_==n); rval=-1e+20; @@ -186,7 +186,7 @@ bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const d }; // returns the gradient computed in eval_f_rterm -bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad) +bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad) { assert(nx_==n); double* grad_vec = grad.local_data(); @@ -196,12 +196,12 @@ bool PriDecMasterProbleEx2Sparse::eval_grad_rterm(size_t idx, const int& n, doub return true; }; -inline size_t PriDecMasterProbleEx2Sparse::get_num_rterms() const +inline size_type PriDecMasterProbleEx2Sparse::get_num_rterms() const { return S_; } -inline size_t PriDecMasterProbleEx2Sparse::get_num_vars() const +inline size_type PriDecMasterProbleEx2Sparse::get_num_vars() const { return nx_; } diff --git a/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp b/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp index 91e4c1da9..f2db47de0 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp @@ -67,7 +67,7 @@ using namespace hiop; class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem { public: - PriDecMasterProbleEx2Sparse(size_t nx, size_t ny, size_t nS, size_t S, std::string mem_space); + PriDecMasterProbleEx2Sparse(size_type nx, size_type ny, size_type nS, size_type S, std::string mem_space); virtual ~PriDecMasterProbleEx2Sparse(); @@ -86,18 +86,18 @@ class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem * n is the number of coupled x, not the entire dimension of x, and might be denoted as nc_ elsewhere. * rval is the return value of the recourse solution function evaluation. */ - bool eval_f_rterm(size_t idx, const int& n, const double* x, double& rval); + bool eval_f_rterm(size_type idx, const int& n, const double* x, double& rval); /** * This function computes the gradient of the recourse solution function w.r.t x. * n is the number of coupled x, not the entire dimension of x, and * grad is the output. */ - bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad); + bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad); - inline size_t get_num_rterms() const; + inline size_type get_num_rterms() const; - inline size_t get_num_vars() const; + inline size_type get_num_vars() const; void get_solution(double* x) const; @@ -105,15 +105,15 @@ class PriDecMasterProbleEx2Sparse : public hiop::hiopInterfacePriDecProblem private: /// dimension of primal variable `x` - size_t nx_; + size_type nx_; /// dimension of the coupled variable, nc_<=nx_ - size_t nc_; + size_type nc_; ///dimension of recourse problem primal variable `y` for each contingency - size_t ny_; + size_type ny_; /// dimension of uncertainty dimension entering the recourse problem - size_t nS_; + size_type nS_; ///number of sample to use, effectively the number of recourse terms - size_t S_; + size_type S_; double* y_; diff --git a/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparseRaja.hpp b/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparseRaja.hpp index 07aecfc63..98f54c478 100644 --- a/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparseRaja.hpp +++ b/src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparseRaja.hpp @@ -50,17 +50,17 @@ class PriDecRecourseProbleEx2Sparse : public hiop::hiopInterfaceSparse { public: PriDecRecourseProbleEx2Sparse(int n, int nS, int S, std::string mem_space) - : nx_(n), - nS_(nS),S_(S), - x_(nullptr), + : x_(nullptr), xi_(nullptr), + nx_(n), + nS_(nS),S_(S), mem_space_(mem_space) { // Make sure mem_space_ is uppercase transform(mem_space_.begin(), mem_space_.end(), mem_space_.begin(), ::toupper); - auto& resmgr = umpire::ResourceManager::getInstance(); - umpire::Allocator allocator = resmgr.getAllocator(mem_space_); + //auto& resmgr = umpire::ResourceManager::getInstance(); + //umpire::Allocator allocator = resmgr.getAllocator(mem_space_); // umpire::Allocator allocator // = resmgr.getAllocator(mem_space_ == "DEFAULT" ? "HOST" : mem_space_); diff --git a/src/Interface/hiopInterfacePrimalDecomp.hpp b/src/Interface/hiopInterfacePrimalDecomp.hpp index 53b4eb02e..e8d4eb102 100644 --- a/src/Interface/hiopInterfacePrimalDecomp.hpp +++ b/src/Interface/hiopInterfacePrimalDecomp.hpp @@ -89,18 +89,18 @@ class hiopInterfacePriDecProblem const double* hess = 0, const char* master_options_file=nullptr) = 0; - virtual bool eval_f_rterm(size_t idx, const int& n, const double* x, double& rval) = 0; - virtual bool eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad) = 0; + virtual bool eval_f_rterm(size_type idx, const int& n, const double* x, double& rval) = 0; + virtual bool eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad) = 0; /** * Returns the number S of recourse terms */ - virtual size_t get_num_rterms() const = 0; + virtual size_type get_num_rterms() const = 0; /** * Return the number of primal optimization variables */ - virtual size_t get_num_vars() const = 0; + virtual size_type get_num_vars() const = 0; virtual void get_solution(double* x) const = 0; virtual double get_objective() = 0; diff --git a/src/Optimization/hiopHessianLowRank.cpp b/src/Optimization/hiopHessianLowRank.cpp index b51c9843b..99cbc1efc 100644 --- a/src/Optimization/hiopHessianLowRank.cpp +++ b/src/Optimization/hiopHessianLowRank.cpp @@ -1034,14 +1034,13 @@ symmMatTimesDiagTimesMatTrans_local(double beta, hiopMatrixDense& W, const hiopVector& d) { size_type k=W.m(); - [[maybe_unused]] const size_type n=X.n(); - size_t n_local=X.get_local_size_n(); + size_type n_local=X.get_local_size_n(); assert(X.m()==k); #ifdef HIOP_DEEPCHECKS assert(W.n()==k); - assert(d.get_size()==n); + assert(d.get_size()==X.n()); assert(d.get_local_size()==n_local); #endif @@ -1059,7 +1058,7 @@ symmMatTimesDiagTimesMatTrans_local(double beta, hiopMatrixDense& W, xj=Xdata+j*n_local; //compute W[i,j] = sum {X[i,p]*d[p]*X[j,p] : p=1,...,n_local} acc=0.0; - for(size_t p=0; p=1); index_type* rsVecDistrib = new index_type[nlen]; rsVecDistrib[0]=0;