QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
projectedconstraint.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2013 Peter Caspers
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file projectedconstraint.hpp
21 \brief Projected constraint
22*/
23
24#ifndef quantlib_optimization_projectedconstraint_h
25#define quantlib_optimization_projectedconstraint_h
26
29#include <utility>
30
31namespace QuantLib {
32
34
35 private:
36
37 class Impl final : public Constraint::Impl {
38 public:
39 Impl(Constraint constraint,
40 const Array& parameterValues,
41 const std::vector<bool>& fixParameters)
42 : constraint_(std::move(constraint)), projection_(parameterValues, fixParameters) {}
43 Impl(Constraint constraint, const Projection& projection)
44 : constraint_(std::move(constraint)), projection_(projection) {}
45 bool test(const Array& params) const override {
46 return constraint_.test(projection_.include(params));
47 }
48 Array upperBound(const Array& params) const override {
50 }
51 Array lowerBound(const Array& params) const override {
53 }
54
55 private:
58 };
59
60 public:
61
63 const Array &parameterValues,
64 const std::vector<bool> &fixParameters)
65 : Constraint(ext::shared_ptr<Constraint::Impl>(
66 new ProjectedConstraint::Impl(constraint, parameterValues,
67 fixParameters))) {}
68
70 const Projection &projection)
71 : Constraint(ext::shared_ptr<Constraint::Impl>(
72 new ProjectedConstraint::Impl(constraint, projection))) {}
73 };
74}
75
76#endif
1-D array used in linear algebra.
Definition: array.hpp:52
Base class for constraint implementations.
Definition: constraint.hpp:38
Base constraint class.
Definition: constraint.hpp:35
bool test(const Array &p) const
Definition: constraint.hpp:57
Array lowerBound(const Array &params) const
Definition: constraint.hpp:66
Array upperBound(const Array &params) const
Definition: constraint.hpp:58
Impl(Constraint constraint, const Array &parameterValues, const std::vector< bool > &fixParameters)
bool test(const Array &params) const override
Tests if params satisfy the constraint.
Impl(Constraint constraint, const Projection &projection)
Array lowerBound(const Array &params) const override
Returns lower bound for given parameters.
Array upperBound(const Array &params) const override
Returns upper bound for given parameters.
ProjectedConstraint(const Constraint &constraint, const Projection &projection)
ProjectedConstraint(const Constraint &constraint, const Array &parameterValues, const std::vector< bool > &fixParameters)
virtual Array include(const Array &projectedParameters) const
returns whole set of parameters corresponding to the set
Definition: projection.cpp:67
virtual Array project(const Array &parameters) const
returns the subset of free parameters corresponding
Definition: projection.cpp:54
Abstract constraint class.
Definition: any.hpp:35
STL namespace.
Parameter projection.