ProteoWizard
DemuxSolver.hpp
Go to the documentation of this file.
1 //
2 // $Id$
3 //
4 //
5 // Original author: Jarrett Egertson <jegertso .@. uw.edu>
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 // http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 
20 #ifndef _DEMUXSOLVER_HPP
21 #define _DEMUXSOLVER_HPP
22 
23 #include "DemuxTypes.hpp"
24 
25 namespace pwiz {
26 namespace analysis {
27  using namespace DemuxTypes;
28 
29  /// Interface for solver that can be used for demultiplexing.
30  /// This is done by solving least squares problems of the form \f[ \min \left\Vert Ax-b\right\Vert_2^2\quad \f] where
31  /// A are the masks (or design matrix), b is the signal (or response), and x is the solution discovered by the solver.
33  {
34  public:
35 
36  /// Shared pointer definition
37  typedef boost::shared_ptr<DemuxSolver> ptr;
38 
39  /// Constant shared pointer definition
40  typedef boost::shared_ptr<const DemuxSolver> const_ptr;
41 
42  /// Perform the least squares solve
43  /// @param[in] masks Design matrix describing which isolation windows are selected for each spectrum.
44  /// @param[in] signal Response matrix describing the signal of each transition in each multiplexed spectrum.
45  /// @param[out] solution Matrix describing the independent spectrum of each isolation window. These are the demultiplexed spectra.
46  ///
47  virtual void Solve(const MatrixPtr& masks, const MatrixPtr& signal, MatrixPtr& solution) = 0;
48 
49  virtual ~DemuxSolver(){}
50  };
51 
52  /// Implementation of the DemuxSolver interface as a non-negative least squares (NNLS) problem.
53  /// That is, the least squares is problem is constrained such that the solution is not negative, or
54  /// \f[ \min \left\Vert Ax-b\right\Vert_2^2\quad s.t.\, x\ge 0 \f]
55  class NNLSSolver : public DemuxSolver
56  {
57  public:
58 
59  /// Constructor for non-negative least squares solver
60  /// @param[in] numIters The maximum number of iterations allowed for convergence
61  /// @param[in] eps Epsilon value for convergence criterion of NNLS solver
62  NNLSSolver(int numIters = 50, double eps = 1e-10) : numIters_(numIters), eps_(eps) {}
63 
64  /// Implementation of DemuxSolver interface
65  void Solve(const MatrixPtr& masks, const MatrixPtr& signal, MatrixPtr& solution) override;
66 
67  private:
68 
69  int numIters_; ///< maximum number of iterations allowed for convergence
70 
71  double eps_; ///< tolerance for convergence
72  };
73 
74 } // namespace analysis
75 } // namespace pwiz
76 #endif // _DEMUXSOLVER_HPP
pwiz::analysis::NNLSSolver
Implementation of the DemuxSolver interface as a non-negative least squares (NNLS) problem.
Definition: DemuxSolver.hpp:56
pwiz
Definition: ChromatogramList_Filter.hpp:36
pwiz::analysis::NNLSSolver::eps_
double eps_
tolerance for convergence
Definition: DemuxSolver.hpp:71
pwiz::analysis::NNLSSolver::Solve
void Solve(const MatrixPtr &masks, const MatrixPtr &signal, MatrixPtr &solution) override
Implementation of DemuxSolver interface.
DemuxTypes::MatrixPtr
boost::shared_ptr< MatrixType > MatrixPtr
Definition: DemuxTypes.hpp:39
pwiz::analysis::DemuxSolver::Solve
virtual void Solve(const MatrixPtr &masks, const MatrixPtr &signal, MatrixPtr &solution)=0
Perform the least squares solve.
DemuxTypes.hpp
pwiz::analysis::NNLSSolver::NNLSSolver
NNLSSolver(int numIters=50, double eps=1e-10)
Constructor for non-negative least squares solver.
Definition: DemuxSolver.hpp:62
DemuxTypes
Definition: DemuxTypes.hpp:35
pwiz::analysis::DemuxSolver
Interface for solver that can be used for demultiplexing.
Definition: DemuxSolver.hpp:33
pwiz::analysis::DemuxSolver::ptr
boost::shared_ptr< DemuxSolver > ptr
Shared pointer definition.
Definition: DemuxSolver.hpp:37
pwiz::analysis::NNLSSolver::numIters_
int numIters_
maximum number of iterations allowed for convergence
Definition: DemuxSolver.hpp:69
pwiz::analysis::DemuxSolver::~DemuxSolver
virtual ~DemuxSolver()
Definition: DemuxSolver.hpp:49
pwiz::analysis::DemuxSolver::const_ptr
boost::shared_ptr< const DemuxSolver > const_ptr
Constant shared pointer definition.
Definition: DemuxSolver.hpp:40