-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #723 from cwentland0/alt_gpod
Add alternative form of weighted Gauss-Newton nonlinear solve
- Loading branch information
Showing
10 changed files
with
522 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...all/solvers_nonlinear/compact_weighted_gaussnewton_normaleqs_custom_types_compile_only.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
#include "pressio/type_traits.hpp" | ||
#include "pressio/ops.hpp" | ||
#include <optional> | ||
|
||
struct CustomVecB{}; | ||
struct CustomMat{}; | ||
|
||
struct MyProblem{ | ||
using state_type = Eigen::VectorXd; | ||
using residual_type = CustomVecB; | ||
using jacobian_type = CustomMat; | ||
state_type createState() const { return state_type{}; } | ||
residual_type createResidual() const { return residual_type{}; } | ||
jacobian_type createJacobian() const { return jacobian_type{}; } | ||
void residualAndJacobian(const state_type& /*x*/, | ||
residual_type& /*r*/, | ||
std::optional<jacobian_type*> /*Jo*/) const{} | ||
}; | ||
|
||
struct Weigher{ | ||
int leadingDim() { return {}; } | ||
void operator()(const CustomVecB & /*operand*/, CustomVecB & /*result*/) const{} | ||
void operator()(const CustomMat & /*operand*/, CustomMat & /*result*/) const{} | ||
}; | ||
|
||
using my_hessian_type = Eigen::MatrixXd; | ||
using my_gradient_type = Eigen::VectorXd; | ||
|
||
namespace pressio{ | ||
template<> struct Traits<CustomVecB>{ | ||
static constexpr int rank = 1; | ||
using scalar_type = double; | ||
}; | ||
template<> struct Traits<CustomMat>{ | ||
static constexpr int rank = 2; | ||
using scalar_type = double; | ||
}; | ||
|
||
namespace ops{ | ||
double norm2(const CustomVecB &){ return {}; } | ||
double dot(const CustomVecB &, const CustomVecB &){ return {}; } | ||
void product(transpose, nontranspose, double, const CustomMat &, const CustomMat &, double, my_hessian_type &){} | ||
void product(transpose, double, const CustomMat &, const CustomVecB &, double, my_gradient_type &){} | ||
void resize(CustomVecB &, int){} | ||
void resize(CustomMat &, int, int){} | ||
std::size_t extent(CustomMat &, int){ return {}; } | ||
}//end namespace ops | ||
}//end namespace pressio | ||
|
||
#include "pressio/solvers_nonlinear_gaussnewton.hpp" | ||
|
||
struct MyLinSolver{ | ||
void solve(const my_hessian_type & /*A*/, | ||
const my_gradient_type & /*b*/, | ||
typename MyProblem::state_type & /*x*/){} | ||
}; | ||
|
||
int main() | ||
{ | ||
pressio::log::initialize(pressio::logto::terminal); | ||
pressio::log::setVerbosity({pressio::log::level::debug}); | ||
{ | ||
using namespace pressio; | ||
using problem_t = MyProblem; | ||
using state_t = typename problem_t::state_type; | ||
using tag_t = nonlinearsolvers::impl::CompactWeightedGaussNewtonNormalEqTag; | ||
problem_t sys; | ||
state_t y; | ||
auto nonLinSolver = create_gauss_newton_solver(sys, MyLinSolver{}, Weigher{}, tag_t{}); | ||
nonLinSolver.solve(y); | ||
(void)y; | ||
std::cout << "PASSED" << std::endl; | ||
} | ||
pressio::log::finalize(); | ||
} |
Oops, something went wrong.