Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROL Trilinos Sync 26-Jun-2020 #7593

Merged
merged 11 commits into from
Jun 29, 2020
Merged
12 changes: 12 additions & 0 deletions packages/rol/adapters/pebbl/src/algorithm/ROL_PEBBL_Driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ROL_PEBBL_Driver {

public:

ROL_PEBBL_Driver(const Ptr<ROL_PEBBL_Branching<Real>> &branching)
: branching_(branching) {}

ROL_PEBBL_Driver(const Ptr<OptimizationProblemFactory<Real>> &factory,
const Ptr<ParameterList> &parlist,
const Ptr<BranchHelper_PEBBL<Real>> &bHelper,
Expand All @@ -46,6 +49,15 @@ class ROL_PEBBL_Driver {
}
return flag;
}

const Ptr<Vector<Real>> getSolution(void) const {
if (branching_ != nullPtr) {
return dynamic_cast<ROL_PEBBL_Solution<Real>*>(branching_->incumbent)->getVector();
}
else {
return nullPtr;
}
}
};

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ROL_PEBBL_Solution : public pebbl::solution {

template<class Real>
class ROL_PEBBL_Branching : public pebbl::branching {
private:
protected:
// OptimizationProblem encapsulates the following problem
// min obj(x)
// subject to xl <= x <= xu
Expand All @@ -99,7 +99,7 @@ class ROL_PEBBL_Branching : public pebbl::branching {
: factory_(factory), parlist_(parlist), bHelper_(bHelper),
verbosity_(verbosity), outStream_(outStream) {}

pebbl::branchSub* blankSub() {
virtual pebbl::branchSub* blankSub() {
return new ROL_PEBBL_BranchSub<Real>(makePtrFromRef<ROL_PEBBL_Branching<Real>>(*this),verbosity_,outStream_);
}

Expand All @@ -126,7 +126,7 @@ class ROL_PEBBL_Branching : public pebbl::branching {

template<class Real>
class ROL_PEBBL_BranchSub : public pebbl::branchSub {
private:
protected:
const Ptr<ROL_PEBBL_Branching<Real>> branching_;
const Ptr<BranchHelper_PEBBL<Real>> bHelper_;
std::map<int,Real> fixed_;
Expand Down Expand Up @@ -306,10 +306,11 @@ class ROL_PEBBL_BranchSub : public pebbl::branchSub {
return (nfrac_==0);
}

void incumbentHeuristic() {
virtual void incumbentHeuristic() {
Real tol(std::sqrt(ROL_EPSILON<Real>()));
rndSolution_->set(*solution_);
rndSolution_->applyUnary(rnd);
problem0_->getObjective()->update(*rndSolution_);
Real val = problem0_->getObjective()->value(*rndSolution_,tol);
branching_->foundSolution(new ROL_PEBBL_Solution<Real>(*rndSolution_,val));
}
Expand Down
37 changes: 30 additions & 7 deletions packages/rol/example/PDE-OPT/TOOLS/assembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ class Assembler {
int myRank_, numProcs_;

// Set in SetBasis.
std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> basisPtrs_;
std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> basisPtrs1_, basisPtrs2_;

// Set in SetDiscretization.
ROL::Ptr<MeshManager<Real>> meshMgr_;
ROL::Ptr<DofManager<Real>> dofMgr_;
ROL::Ptr<DofManager<Real>> dofMgr1_, dofMgr2_;

// Set in SetParallelStructure.
int numCells_;
Expand Down Expand Up @@ -216,7 +216,8 @@ class Assembler {
Teuchos::ParameterList &parlist,
std::ostream &outStream = std::cout);
void setBasis(
const std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> &basisPtrs,
const std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> &basisPtrs1,
const std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> &basisPtrs2,
Teuchos::ParameterList &parlist,
std::ostream &outStream = std::cout);
void setDiscretization(Teuchos::ParameterList &parlist,
Expand All @@ -237,16 +238,24 @@ class Assembler {
Real assembleScalar(ROL::Ptr<Intrepid::FieldContainer<Real>> &val);
void assembleFieldVector(ROL::Ptr<Tpetra::MultiVector<>> &v,
ROL::Ptr<Intrepid::FieldContainer<Real>> &val,
ROL::Ptr<Tpetra::MultiVector<>> &vecOverlap);
ROL::Ptr<Tpetra::MultiVector<>> &vecOverlap,
const ROL::Ptr<DofManager<Real>> &dofMgr);
void assembleParamVector(ROL::Ptr<std::vector<Real>> &v,
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> &val);
void assembleFieldMatrix(ROL::Ptr<Tpetra::CrsMatrix<>> &M,
ROL::Ptr<Intrepid::FieldContainer<Real>> &val);
ROL::Ptr<Intrepid::FieldContainer<Real>> &val,
const ROL::Ptr<DofManager<Real>> &dofMgr1,
const ROL::Ptr<DofManager<Real>> &dofMgr2);
void assembleParamFieldMatrix(ROL::Ptr<Tpetra::MultiVector<>> &M,
std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>> &val,
ROL::Ptr<Tpetra::MultiVector<>> &matOverlap);
ROL::Ptr<Tpetra::MultiVector<>> &matOverlap,
const ROL::Ptr<DofManager<Real>> &dofMgr);
void assembleParamMatrix(ROL::Ptr<std::vector<std::vector<Real>>> &M,
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> &val);
std::vector<std::vector<ROL::Ptr<Intrepid::FieldContainer<Real>>>> &val,
const ROL::Ptr<DofManager<Real>> &dofMgr);
void transformToFieldPattern(const ROL::Ptr<Intrepid::FieldContainer<Real>> &array,
const ROL::Ptr<DofManager<Real>> &dofMgr1,
const ROL::Ptr<DofManager<Real>> &dofMgr2 = ROL::nullPtr) const;

public:
// destructor
Expand All @@ -262,6 +271,19 @@ class Assembler {
const ROL::Ptr<const Teuchos::Comm<int>> &comm,
Teuchos::ParameterList &parlist,
std::ostream &outStream = std::cout);
// Constuctor: Discretization set from ParameterList
Assembler(const std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> &basisPtrs1,
const std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> &basisPtrs2,
const ROL::Ptr<const Teuchos::Comm<int>> &comm,
Teuchos::ParameterList &parlist,
std::ostream &outStream = std::cout);
// Constructor: Discretization set from MeshManager input
Assembler(const std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> &basisPtrs1,
const std::vector<ROL::Ptr<Intrepid::Basis<Real, Intrepid::FieldContainer<Real>>>> &basisPtrs2,
const ROL::Ptr<MeshManager<Real>> &meshMgr,
const ROL::Ptr<const Teuchos::Comm<int>> &comm,
Teuchos::ParameterList &parlist,
std::ostream &outStream = std::cout);
void setCellNodes(PDE<Real> &pde) const;
void setCellNodes(DynamicPDE<Real> &pde) const;

Expand Down Expand Up @@ -687,6 +709,7 @@ class Assembler {
/* Accessor routines. */
/***************************************************************************/
const ROL::Ptr<DofManager<Real>> getDofManager(void) const;
const ROL::Ptr<DofManager<Real>> getDofManager2(void) const;
Teuchos::Array<GO> getCellIds(void) const;
/***************************************************************************/
/* End of accessor routines. */
Expand Down
Loading