Skip to content

Commit

Permalink
pass quartz CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nychiang committed Aug 24, 2023
1 parent 304c68d commit f8f97a5
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 73 deletions.
4 changes: 2 additions & 2 deletions src/Drivers/PriDec/NlpPriDecEx1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<n; i++) {
Expand All @@ -273,7 +273,7 @@ bool PriDecMasterProblemEx1::eval_f_rterm(size_t idx, const int& n,const double
};

// x is handled by primalDecomp to be the correct coupled x
bool PriDecMasterProblemEx1::eval_grad_rterm(size_t idx, const int& n, double* x, hiopVector& grad)
bool PriDecMasterProblemEx1::eval_grad_rterm(size_type idx, const int& n, double* x, hiopVector& grad)
{
assert(static_cast<int>(nc_) == n);
double* grad_vec = grad.local_data();
Expand Down
14 changes: 7 additions & 7 deletions src/Drivers/PriDec/NlpPriDecEx1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
{
Expand All @@ -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_;
Expand Down
10 changes: 5 additions & 5 deletions src/Drivers/PriDec/NlpPriDecEx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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_;
}
Expand Down
20 changes: 10 additions & 10 deletions src/Drivers/PriDec/NlpPriDecEx2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -86,34 +86,34 @@ 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;

double get_objective();

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_;

Expand Down
10 changes: 5 additions & 5 deletions src/Drivers/PriDec/NlpPriDecEx2Sparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_];
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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_;
}
Expand Down
20 changes: 10 additions & 10 deletions src/Drivers/PriDec/NlpPriDecEx2Sparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -85,34 +85,34 @@ 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;

double get_objective();

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_;

Expand Down
10 changes: 5 additions & 5 deletions src/Drivers/PriDec/NlpPriDecEx2SparseRaja.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using ex9_raja_reduce = hiop::ExecRajaPoliciesBackend<hiop::ExecPolicyRajaOmp>::
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),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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_;
}
Expand Down
20 changes: 10 additions & 10 deletions src/Drivers/PriDec/NlpPriDecEx2SparseRaja.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -86,34 +86,34 @@ 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;

double get_objective();

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_;

Expand Down
10 changes: 5 additions & 5 deletions src/Drivers/PriDec/NlpPriDecEx2UserRecourseSparseRaja.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);

Expand Down
8 changes: 4 additions & 4 deletions src/Interface/hiopInterfacePrimalDecomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit f8f97a5

Please sign in to comment.