From bfda398b2503bc5224e9aa43cd9e0d90e80c1ce5 Mon Sep 17 00:00:00 2001 From: nychiang Date: Thu, 5 Oct 2023 12:44:54 -0700 Subject: [PATCH 1/2] update hiop interface due to the latest changes in hiop --- src/scopflow/solver/hiop/scopflow_hiop.cpp | 12 ++++++------ src/scopflow/solver/hiop/scopflow_hiop.h | 8 ++++---- src/sopflow/solver/hiop/sopflow_hiop.cpp | 8 ++++---- src/sopflow/solver/hiop/sopflow_hiop.h | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/scopflow/solver/hiop/scopflow_hiop.cpp b/src/scopflow/solver/hiop/scopflow_hiop.cpp index 1aee91be..627b863b 100644 --- a/src/scopflow/solver/hiop/scopflow_hiop.cpp +++ b/src/scopflow/solver/hiop/scopflow_hiop.cpp @@ -155,7 +155,7 @@ extern PetscErrorCode SCOPFLOWUpdateOPFLOWVariableBounds(OPFLOW, Vec, Vec, /* Note: x only holds the coupled variables which, in this case, are the generator real power variables for the base-case */ -bool SCOPFLOWHIOPInterface::eval_f_rterm(size_t idx, const int &n, +bool SCOPFLOWHIOPInterface::eval_f_rterm(hiop::size_type idx, const int &n, const double *x, double &rval) { PetscErrorCode ierr; OPFLOW opflow0; /* base case OPFLOW */ @@ -245,7 +245,7 @@ bool SCOPFLOWHIOPInterface::eval_f_rterm(size_t idx, const int &n, return true; } -bool SCOPFLOWHIOPInterface::eval_grad_rterm(size_t idx, const int &n, double *x, +bool SCOPFLOWHIOPInterface::eval_grad_rterm(hiop::size_type idx, const int &n, double *x, hiop::hiopVector &gradvec) { (void)idx; (void)n; @@ -310,12 +310,12 @@ bool SCOPFLOWHIOPInterface::eval_grad_rterm(size_t idx, const int &n, double *x, return true; } -size_t SCOPFLOWHIOPInterface::get_num_rterms() const { - return scopflow->Nc - 1; +hiop::size_type SCOPFLOWHIOPInterface::get_num_rterms() const { + return (hiop::size_type) scopflow->Nc - 1; } -size_t SCOPFLOWHIOPInterface::get_num_vars() const { - return scopflow->opflow0->nx; +hiop::size_type SCOPFLOWHIOPInterface::get_num_vars() const { + return (hiop::size_type) scopflow->opflow0->nx; } void SCOPFLOWHIOPInterface::get_solution(double *x) const { diff --git a/src/scopflow/solver/hiop/scopflow_hiop.h b/src/scopflow/solver/hiop/scopflow_hiop.h index b01f50b4..10dbbe66 100644 --- a/src/scopflow/solver/hiop/scopflow_hiop.h +++ b/src/scopflow/solver/hiop/scopflow_hiop.h @@ -23,13 +23,13 @@ class SCOPFLOWHIOPInterface : public hiop::hiopInterfacePriDecProblem { const double *hess, const char *master_options_file); - bool eval_f_rterm(size_t idx, const int &n, const double *x, double &rval); - bool eval_grad_rterm(size_t idx, const int &n, double *x, + bool eval_f_rterm(hiop::size_type idx, const int &n, const double *x, double &rval); + bool eval_grad_rterm(hiop::size_type idx, const int &n, double *x, hiop::hiopVector &grad); - size_t get_num_rterms() const; + hiop::size_type get_num_rterms() const; - size_t get_num_vars() const; + hiop::size_type get_num_vars() const; void get_solution(double *x) const; diff --git a/src/sopflow/solver/hiop/sopflow_hiop.cpp b/src/sopflow/solver/hiop/sopflow_hiop.cpp index c5cd759a..8c2ce05a 100644 --- a/src/sopflow/solver/hiop/sopflow_hiop.cpp +++ b/src/sopflow/solver/hiop/sopflow_hiop.cpp @@ -164,7 +164,7 @@ extern PetscErrorCode SOPFLOWUpdateOPFLOWVariableBounds(OPFLOW, Vec, Vec, /* Note: x only holds the coupled variables which, in this case, are the generator real power variables for the base-case */ -bool SOPFLOWHIOPInterface::eval_f_rterm(size_t idx, const int &n, +bool SOPFLOWHIOPInterface::eval_f_rterm(hiop::size_type idx, const int &n, const double *x, double &rval) { (void)n; PetscErrorCode ierr; @@ -283,7 +283,7 @@ bool SOPFLOWHIOPInterface::eval_f_rterm(size_t idx, const int &n, return true; } -bool SOPFLOWHIOPInterface::eval_grad_rterm(size_t idx, const int &n, double *x, +bool SOPFLOWHIOPInterface::eval_grad_rterm(hiop::size_type idx, const int &n, double *x, hiop::hiopVector &gradvec) { (void)idx; (void)n; @@ -349,11 +349,11 @@ bool SOPFLOWHIOPInterface::eval_grad_rterm(size_t idx, const int &n, double *x, return true; } -size_t SOPFLOWHIOPInterface::get_num_rterms() const { +hiop::size_type SOPFLOWHIOPInterface::get_num_rterms() const { return (sopflow->Ns * sopflow->Nc) - 1; } -size_t SOPFLOWHIOPInterface::get_num_vars() const { +hiop::size_type SOPFLOWHIOPInterface::get_num_vars() const { return sopflow->opflow0->nx; } diff --git a/src/sopflow/solver/hiop/sopflow_hiop.h b/src/sopflow/solver/hiop/sopflow_hiop.h index b3f32d69..aeedfa05 100644 --- a/src/sopflow/solver/hiop/sopflow_hiop.h +++ b/src/sopflow/solver/hiop/sopflow_hiop.h @@ -24,13 +24,13 @@ class SOPFLOWHIOPInterface : public hiop::hiopInterfacePriDecProblem { const double *hess, const char *master_options_file); - bool eval_f_rterm(size_t idx, const int &n, const double *x, double &rval); - bool eval_grad_rterm(size_t idx, const int &n, double *x, + bool eval_f_rterm(hiop::size_type idx, const int &n, const double *x, double &rval); + bool eval_grad_rterm(hiop::size_type idx, const int &n, double *x, hiop::hiopVector &grad); - size_t get_num_rterms() const; + hiop::size_type get_num_rterms() const; - size_t get_num_vars() const; + hiop::size_type get_num_vars() const; void get_solution(double *x) const; From aed5579d208aad98638907c8874d7849e01ad22d Mon Sep 17 00:00:00 2001 From: nychiang Date: Thu, 5 Oct 2023 21:12:14 +0000 Subject: [PATCH 2/2] Apply pre-commmit fixes --- src/scopflow/solver/hiop/scopflow_hiop.cpp | 7 ++++--- src/scopflow/solver/hiop/scopflow_hiop.h | 3 ++- src/sopflow/solver/hiop/sopflow_hiop.cpp | 3 ++- src/sopflow/solver/hiop/sopflow_hiop.h | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/scopflow/solver/hiop/scopflow_hiop.cpp b/src/scopflow/solver/hiop/scopflow_hiop.cpp index 627b863b..7dcfa19a 100644 --- a/src/scopflow/solver/hiop/scopflow_hiop.cpp +++ b/src/scopflow/solver/hiop/scopflow_hiop.cpp @@ -245,7 +245,8 @@ bool SCOPFLOWHIOPInterface::eval_f_rterm(hiop::size_type idx, const int &n, return true; } -bool SCOPFLOWHIOPInterface::eval_grad_rterm(hiop::size_type idx, const int &n, double *x, +bool SCOPFLOWHIOPInterface::eval_grad_rterm(hiop::size_type idx, const int &n, + double *x, hiop::hiopVector &gradvec) { (void)idx; (void)n; @@ -311,11 +312,11 @@ bool SCOPFLOWHIOPInterface::eval_grad_rterm(hiop::size_type idx, const int &n, d } hiop::size_type SCOPFLOWHIOPInterface::get_num_rterms() const { - return (hiop::size_type) scopflow->Nc - 1; + return (hiop::size_type)scopflow->Nc - 1; } hiop::size_type SCOPFLOWHIOPInterface::get_num_vars() const { - return (hiop::size_type) scopflow->opflow0->nx; + return (hiop::size_type)scopflow->opflow0->nx; } void SCOPFLOWHIOPInterface::get_solution(double *x) const { diff --git a/src/scopflow/solver/hiop/scopflow_hiop.h b/src/scopflow/solver/hiop/scopflow_hiop.h index 10dbbe66..834cb2ff 100644 --- a/src/scopflow/solver/hiop/scopflow_hiop.h +++ b/src/scopflow/solver/hiop/scopflow_hiop.h @@ -23,7 +23,8 @@ class SCOPFLOWHIOPInterface : public hiop::hiopInterfacePriDecProblem { const double *hess, const char *master_options_file); - bool eval_f_rterm(hiop::size_type idx, const int &n, const double *x, double &rval); + bool eval_f_rterm(hiop::size_type idx, const int &n, const double *x, + double &rval); bool eval_grad_rterm(hiop::size_type idx, const int &n, double *x, hiop::hiopVector &grad); diff --git a/src/sopflow/solver/hiop/sopflow_hiop.cpp b/src/sopflow/solver/hiop/sopflow_hiop.cpp index 8c2ce05a..8b933ca5 100644 --- a/src/sopflow/solver/hiop/sopflow_hiop.cpp +++ b/src/sopflow/solver/hiop/sopflow_hiop.cpp @@ -283,7 +283,8 @@ bool SOPFLOWHIOPInterface::eval_f_rterm(hiop::size_type idx, const int &n, return true; } -bool SOPFLOWHIOPInterface::eval_grad_rterm(hiop::size_type idx, const int &n, double *x, +bool SOPFLOWHIOPInterface::eval_grad_rterm(hiop::size_type idx, const int &n, + double *x, hiop::hiopVector &gradvec) { (void)idx; (void)n; diff --git a/src/sopflow/solver/hiop/sopflow_hiop.h b/src/sopflow/solver/hiop/sopflow_hiop.h index aeedfa05..0aab4ffd 100644 --- a/src/sopflow/solver/hiop/sopflow_hiop.h +++ b/src/sopflow/solver/hiop/sopflow_hiop.h @@ -24,7 +24,8 @@ class SOPFLOWHIOPInterface : public hiop::hiopInterfacePriDecProblem { const double *hess, const char *master_options_file); - bool eval_f_rterm(hiop::size_type idx, const int &n, const double *x, double &rval); + bool eval_f_rterm(hiop::size_type idx, const int &n, const double *x, + double &rval); bool eval_grad_rterm(hiop::size_type idx, const int &n, double *x, hiop::hiopVector &grad);