Skip to content

Commit

Permalink
try to fix the CI tests on github (#654)
Browse files Browse the repository at this point in the history
* try to fix the CI tests on github

* try to fix the CI tests on github

* add deepcheck

* pass quartz CI

* build on lassen

* remove some unused var

* fix PNNL CI v1

* try to fix ginkgo issue
  • Loading branch information
nychiang committed Sep 29, 2023
1 parent cd03287 commit 25d6eaf
Show file tree
Hide file tree
Showing 53 changed files with 262 additions and 281 deletions.
3 changes: 2 additions & 1 deletion src/Drivers/Dense/NlpDenseConsEx1Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ static void usage(const char* exeName)

int main(int argc, char **argv)
{
int rank=0, numRanks=1;
int rank = 0;
#ifdef HIOP_USE_MPI
int numRanks = 1;
int err;
err = MPI_Init(&argc, &argv); assert(MPI_SUCCESS==err);
err = MPI_Comm_rank(MPI_COMM_WORLD,&rank); assert(MPI_SUCCESS==err);
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Dense/NlpDenseConsEx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
DenseConsEx2::DenseConsEx2(int n, bool unconstrained)
: n_vars_(n),
n_cons_(4),
comm(MPI_COMM_WORLD),
unconstrained_(unconstrained)
{
comm_size = 1;
my_rank = 0;
#ifdef HIOP_USE_MPI
comm = MPI_COMM_WORLD;
int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr);
ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr);
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/Drivers/Dense/NlpDenseConsEx2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ class DenseConsEx2 : public hiop::hiopInterfaceDenseConstraints
*/
private:
size_type n_vars_, n_cons_;
#ifdef HIOP_USE_MPI
MPI_Comm comm;
#endif
int my_rank;
int comm_size;
index_type* col_partition_;
Expand Down
5 changes: 4 additions & 1 deletion src/Drivers/Dense/NlpDenseConsEx3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ class DenseConsEx3 : public hiop::hiopInterfaceDenseConstraints
{
public:
DenseConsEx3(int n)
: n_vars(n), n_cons(2), comm(MPI_COMM_WORLD)
: n_vars(n), n_cons(2)
{
comm_size=1; my_rank=0;
#ifdef HIOP_USE_MPI
comm = MPI_COMM_WORLD;
int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr);
ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr);
#endif
Expand Down Expand Up @@ -226,7 +227,9 @@ class DenseConsEx3 : public hiop::hiopInterfaceDenseConstraints

private:
int n_vars, n_cons;
#ifdef HIOP_USE_MPI
MPI_Comm comm;
#endif
int my_rank, comm_size;
index_type* col_partition;
public:
Expand Down
2 changes: 1 addition & 1 deletion src/Drivers/Dense/NlpDenseConsEx4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
DenseConsEx4::DenseConsEx4()
: n_vars_(2),
n_cons_(4),
comm(MPI_COMM_WORLD),
unconstrained_(false)
{
comm_size = 1;
my_rank = 0;
#ifdef HIOP_USE_MPI
comm = MPI_COMM_WORLD;
int ierr = MPI_Comm_size(comm, &comm_size); assert(MPI_SUCCESS==ierr);
ierr = MPI_Comm_rank(comm, &my_rank); assert(MPI_SUCCESS==ierr);
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/Drivers/Dense/NlpDenseConsEx4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ class DenseConsEx4 : public hiop::hiopInterfaceDenseConstraints
*/
private:
size_type n_vars_, n_cons_;
#ifdef HIOP_USE_MPI
MPI_Comm comm;
#endif
int my_rank;
int comm_size;
index_type* col_partition_;
Expand Down
4 changes: 2 additions & 2 deletions src/Drivers/MDS/NlpMdsRajaEx1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ using hiopMatrixRajaDense = hiop::hiopMatrixDenseRaja<hiop::MemBackendUmpire, hi
using namespace hiop;

MdsEx1::MdsEx1(int ns_in, int nd_in, std::string mem_space, bool empty_sp_row)
: mem_space_(mem_space),
ns_(ns_in),
: ns_(ns_in),
mem_space_(mem_space),
sol_x_(NULL),
sol_zl_(NULL),
sol_zu_(NULL),
Expand Down
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
18 changes: 10 additions & 8 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,16 +103,17 @@ 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;
hiopSolveStatus status;
double* xi;
hiopSolveStatus status;

#ifdef HIOP_USE_MPI
double t3 = MPI_Wtime();
double t4 = 0.;
// uncomment if want to monitor contingency computing time
//double t3 = MPI_Wtime();
//double t4 = 0.;
#endif

// xi can be set below
Expand Down Expand Up @@ -149,6 +150,7 @@ bool PriDecMasterProbleEx2::eval_f_rterm(size_t idx, const int& n, const double*

//assert("for debugging" && false); //for debugging purpose
status = solver.run();
assert(status<=hiopSolveStatus::User_Stopped); //check solver status if necessary
rval = solver.getObjective();
if(y_==NULL) {
y_ = new double[ny_];
Expand All @@ -171,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 @@ -181,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
16 changes: 9 additions & 7 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,16 +95,17 @@ 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;
hiopSolveStatus status;
double* xi;

#ifdef HIOP_USE_MPI
double t3 = MPI_Wtime();
double t4 = 0.;
// uncomment if want to monitor contingency computing time
//double t3 = MPI_Wtime();
//double t4 = 0.;
#endif

xi = new double[nS_];
Expand Down Expand Up @@ -142,6 +143,7 @@ bool PriDecMasterProbleEx2Sparse::eval_f_rterm(size_t idx, const int& n, const d

//assert("for debugging" && false); //for debugging purpose
status = solver.run();
assert(status<=hiopSolveStatus::User_Stopped); //check solver status if necessary
rval = solver.getObjective();
if(y_==nullptr) {
y_ = new double[ny_];
Expand All @@ -164,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 @@ -174,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
Loading

0 comments on commit 25d6eaf

Please sign in to comment.