From 0b5c9d6993caa78bf9a8e63f0e562aca7019d378 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Sun, 18 Aug 2024 13:43:42 +0200 Subject: Added linear model. --- topology.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'topology.cpp') diff --git a/topology.cpp b/topology.cpp index e89e3eb..6650ea6 100644 --- a/topology.cpp +++ b/topology.cpp @@ -60,7 +60,7 @@ public: virtual std::tuple H_∂H_∂∂H(const Vector& x) const { Tensor t(M, N, N); - Tensor ∂∂H = t.setConstant(0); + Tensor ∂∂H = t.setZero(); Matrix ∂H = Matrix::Zero(M, N); Vector H = Vector::Zero(M); return {H, ∂H, ∂∂H}; @@ -143,6 +143,26 @@ public: } }; +class ExtensiveLinear : public ConstraintModel { +private: + Matrix A; + +public: + ExtensiveLinear(unsigned N, unsigned M, Real E, Rng& r) : ConstraintModel(N, M, E, r), A(M, N) { + for (Real& Aij : A.reshaped()) { + Aij = r.variate(0, sqrt(1.0 / N)); + } + } + + std::tuple H_∂H_∂∂H(const Vector& x) const override { + Tensor ∂∂H(M, N, N); + ∂∂H.setZero(); + Matrix ∂H = A; + Vector H = A * x; + return {H, ∂H, ∂∂H}; + } +}; + class ExtensiveQuadratic : public ConstraintModel { private: Tensor J; -- cgit v1.2.3-70-g09d2