ROOT logo
// @(#)root/quadp:$Id: TQpSolverBase.h 20882 2007-11-19 11:31:26Z rdm $
// Author: Eddy Offermann   May 2004

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

/*************************************************************************
 * Parts of this file are copied from the OOQP distribution and          *
 * are subject to the following license:                                 *
 *                                                                       *
 * COPYRIGHT 2001 UNIVERSITY OF CHICAGO                                  *
 *                                                                       *
 * The copyright holder hereby grants you royalty-free rights to use,    *
 * reproduce, prepare derivative works, and to redistribute this software*
 * to others, provided that any changes are clearly documented. This     *
 * software was authored by:                                             *
 *                                                                       *
 *   E. MICHAEL GERTZ      gertz@mcs.anl.gov                             *
 *   Mathematics and Computer Science Division                           *
 *   Argonne National Laboratory                                         *
 *   9700 S. Cass Avenue                                                 *
 *   Argonne, IL 60439-4844                                              *
 *                                                                       *
 *   STEPHEN J. WRIGHT     swright@cs.wisc.edu                           *
 *   Computer Sciences Department                                        *
 *   University of Wisconsin                                             *
 *   1210 West Dayton Street                                             *
 *   Madison, WI 53706   FAX: (608)262-9777                              *
 *                                                                       *
 * Any questions or comments may be directed to one of the authors.      *
 *                                                                       *
 * ARGONNE NATIONAL LABORATORY (ANL), WITH FACILITIES IN THE STATES OF   *
 * ILLINOIS AND IDAHO, IS OWNED BY THE UNITED STATES GOVERNMENT, AND     *
 * OPERATED BY THE UNIVERSITY OF CHICAGO UNDER PROVISION OF A CONTRACT   *
 * WITH THE DEPARTMENT OF ENERGY.                                        *
 *************************************************************************/

#ifndef ROOT_TQpSolverBase
#define ROOT_TQpSolverBase

#ifndef ROOT_TError
#include "TError.h"
#endif

#ifndef ROOT_TQpVar
#include "TQpVar.h"
#endif
#ifndef ROOT_TQpDataBase
#include "TQpDataBase.h"
#endif
#ifndef ROOT_TQpResidual
#include "TQpResidual.h"
#endif
#ifndef ROOT_TQpProbBase
#include "TQpProbBase.h"
#endif
#ifndef ROOT_TQpLinSolverBase
#include "TQpLinSolverBase.h"
#endif

#ifndef ROOT_TMatrixD
#include "TMatrixD.h"
#endif

///////////////////////////////////////////////////////////////////////////
//                                                                       //
// Abstract base class for QP solver using interior-point                //
//                                                                       //
///////////////////////////////////////////////////////////////////////////

enum ETerminationCode
{
   kSUCCESSFUL_TERMINATION = 0,
   kNOT_FINISHED,
   kMAX_ITS_EXCEEDED,
   kINFEASIBLE,
   kUNKNOWN
};

class TQpSolverBase : public TObject
{

protected:
   TQpLinSolverBase *fSys;

   Double_t          fDnorm;                   // norm of problem data

   Double_t          fMutol;                   // termination parameters
   Double_t          fArtol;

   Double_t          fGamma_f;                 // parameters associated with the step length heuristic
   Double_t          fGamma_a;
   Double_t          fPhi;                     // merit function, defined as the sum of the complementarity gap
                                               // the residual norms, divided by (1+norm of problem data)
   Int_t             fMaxit;                   // maximum number of  iterations allowed

   Double_t         *fMu_history;              //[fMaxit] history of values of mu obtained on all iterations to date
   Double_t         *fRnorm_history;           //[fMaxit] history of values of residual norm obtained on all iterations to date
   Double_t         *fPhi_history;             //[fMaxit] history of values of phi obtained on all iterations to date

   Double_t         *fPhi_min_history;         //[fMaxit] the i-th entry of this array contains the minimum value of phi
                                               //          encountered by the algorithm on or before iteration i

public:
   Int_t             fIter;                    // iteration counter

   TQpSolverBase();
   TQpSolverBase(const TQpSolverBase &another);

   virtual ~TQpSolverBase();

   virtual void     Start       (TQpProbBase *formulation,
                                 TQpVar *iterate,TQpDataBase *prob,
                                 TQpResidual *resid,TQpVar *step);
                                               // starting point heuristic
   virtual void     DefStart    (TQpProbBase *formulation,
                                 TQpVar *iterate,TQpDataBase *prob,
                                 TQpResidual *resid,TQpVar *step);
                                               // default starting point heuristic
   virtual void     SteveStart  (TQpProbBase *formulation,
                                 TQpVar *iterate,TQpDataBase *prob,
                                 TQpResidual *resid,TQpVar *step);
                                               // alternative starting point heuristic
   virtual void     DumbStart   (TQpProbBase *formulation,
                                 TQpVar *iterate,TQpDataBase *prob,
                                 TQpResidual *resid,TQpVar *step);
                                               // alternative starting point heuristic: sets the
                                               // "complementary" variables to a large positive value
                                                // (based on the norm of the problem data) and the
                                               // remaining variables to zero

   virtual Int_t    Solve       (TQpDataBase *prob,TQpVar *iterate,
                                 TQpResidual *resids) = 0;
                                               // implements the interior-point method for solving the QP

   virtual Double_t FinalStepLength
                                (TQpVar *iterate,TQpVar *step);
                                               // Mehrotra's heuristic to calculate the final step

   virtual void     DoMonitor   (TQpDataBase *data,TQpVar *vars,
                                 TQpResidual *resids,Double_t alpha,
                                 Double_t sigma,Int_t i,Double_t mu,
                                 Int_t stop_code,Int_t level);
                                               // perform monitor operation at each interior-point iteration
   virtual void     DefMonitor  (TQpDataBase *data,TQpVar *vars,
                                 TQpResidual *resids,Double_t alpha,
                                 Double_t sigma,Int_t i,Double_t mu,
                                 Int_t stop_code,Int_t level) = 0;
                                               // default monitor: prints out one line of information
                                               // on each interior-point iteration
   virtual Int_t    DoStatus    (TQpDataBase *data,TQpVar *vars,
                                 TQpResidual *resids,Int_t i,Double_t mu,
                                 Int_t level);
                                               // this method called to test for convergence status at
                                               // at the end of each interior-point iteration
   virtual Int_t    DefStatus   (TQpDataBase *data,TQpVar *vars,
                                 TQpResidual *resids,Int_t i,Double_t mu,
                                 Int_t level);
                                               // default method for checking status. May be replaced
                                               // by a user-defined method

   TQpLinSolverBase *GetLinearSystem()            { return fSys; }
   void              SetMuTol       (Double_t m)  { fMutol = m; }
   Double_t          GetMuTol       ()            { return fMutol; }

   void              SetArTol       (Double_t ar) { fArtol = ar; }
   Double_t          GetArTol       ()            { return fArtol; }
   Double_t          DataNorm       ()            { return fDnorm; }

   TQpSolverBase &operator= (const TQpSolverBase &source);

   ClassDef(TQpSolverBase,1)                   // Qp Solver class
};
#endif
 TQpSolverBase.h:1
 TQpSolverBase.h:2
 TQpSolverBase.h:3
 TQpSolverBase.h:4
 TQpSolverBase.h:5
 TQpSolverBase.h:6
 TQpSolverBase.h:7
 TQpSolverBase.h:8
 TQpSolverBase.h:9
 TQpSolverBase.h:10
 TQpSolverBase.h:11
 TQpSolverBase.h:12
 TQpSolverBase.h:13
 TQpSolverBase.h:14
 TQpSolverBase.h:15
 TQpSolverBase.h:16
 TQpSolverBase.h:17
 TQpSolverBase.h:18
 TQpSolverBase.h:19
 TQpSolverBase.h:20
 TQpSolverBase.h:21
 TQpSolverBase.h:22
 TQpSolverBase.h:23
 TQpSolverBase.h:24
 TQpSolverBase.h:25
 TQpSolverBase.h:26
 TQpSolverBase.h:27
 TQpSolverBase.h:28
 TQpSolverBase.h:29
 TQpSolverBase.h:30
 TQpSolverBase.h:31
 TQpSolverBase.h:32
 TQpSolverBase.h:33
 TQpSolverBase.h:34
 TQpSolverBase.h:35
 TQpSolverBase.h:36
 TQpSolverBase.h:37
 TQpSolverBase.h:38
 TQpSolverBase.h:39
 TQpSolverBase.h:40
 TQpSolverBase.h:41
 TQpSolverBase.h:42
 TQpSolverBase.h:43
 TQpSolverBase.h:44
 TQpSolverBase.h:45
 TQpSolverBase.h:46
 TQpSolverBase.h:47
 TQpSolverBase.h:48
 TQpSolverBase.h:49
 TQpSolverBase.h:50
 TQpSolverBase.h:51
 TQpSolverBase.h:52
 TQpSolverBase.h:53
 TQpSolverBase.h:54
 TQpSolverBase.h:55
 TQpSolverBase.h:56
 TQpSolverBase.h:57
 TQpSolverBase.h:58
 TQpSolverBase.h:59
 TQpSolverBase.h:60
 TQpSolverBase.h:61
 TQpSolverBase.h:62
 TQpSolverBase.h:63
 TQpSolverBase.h:64
 TQpSolverBase.h:65
 TQpSolverBase.h:66
 TQpSolverBase.h:67
 TQpSolverBase.h:68
 TQpSolverBase.h:69
 TQpSolverBase.h:70
 TQpSolverBase.h:71
 TQpSolverBase.h:72
 TQpSolverBase.h:73
 TQpSolverBase.h:74
 TQpSolverBase.h:75
 TQpSolverBase.h:76
 TQpSolverBase.h:77
 TQpSolverBase.h:78
 TQpSolverBase.h:79
 TQpSolverBase.h:80
 TQpSolverBase.h:81
 TQpSolverBase.h:82
 TQpSolverBase.h:83
 TQpSolverBase.h:84
 TQpSolverBase.h:85
 TQpSolverBase.h:86
 TQpSolverBase.h:87
 TQpSolverBase.h:88
 TQpSolverBase.h:89
 TQpSolverBase.h:90
 TQpSolverBase.h:91
 TQpSolverBase.h:92
 TQpSolverBase.h:93
 TQpSolverBase.h:94
 TQpSolverBase.h:95
 TQpSolverBase.h:96
 TQpSolverBase.h:97
 TQpSolverBase.h:98
 TQpSolverBase.h:99
 TQpSolverBase.h:100
 TQpSolverBase.h:101
 TQpSolverBase.h:102
 TQpSolverBase.h:103
 TQpSolverBase.h:104
 TQpSolverBase.h:105
 TQpSolverBase.h:106
 TQpSolverBase.h:107
 TQpSolverBase.h:108
 TQpSolverBase.h:109
 TQpSolverBase.h:110
 TQpSolverBase.h:111
 TQpSolverBase.h:112
 TQpSolverBase.h:113
 TQpSolverBase.h:114
 TQpSolverBase.h:115
 TQpSolverBase.h:116
 TQpSolverBase.h:117
 TQpSolverBase.h:118
 TQpSolverBase.h:119
 TQpSolverBase.h:120
 TQpSolverBase.h:121
 TQpSolverBase.h:122
 TQpSolverBase.h:123
 TQpSolverBase.h:124
 TQpSolverBase.h:125
 TQpSolverBase.h:126
 TQpSolverBase.h:127
 TQpSolverBase.h:128
 TQpSolverBase.h:129
 TQpSolverBase.h:130
 TQpSolverBase.h:131
 TQpSolverBase.h:132
 TQpSolverBase.h:133
 TQpSolverBase.h:134
 TQpSolverBase.h:135
 TQpSolverBase.h:136
 TQpSolverBase.h:137
 TQpSolverBase.h:138
 TQpSolverBase.h:139
 TQpSolverBase.h:140
 TQpSolverBase.h:141
 TQpSolverBase.h:142
 TQpSolverBase.h:143
 TQpSolverBase.h:144
 TQpSolverBase.h:145
 TQpSolverBase.h:146
 TQpSolverBase.h:147
 TQpSolverBase.h:148
 TQpSolverBase.h:149
 TQpSolverBase.h:150
 TQpSolverBase.h:151
 TQpSolverBase.h:152
 TQpSolverBase.h:153
 TQpSolverBase.h:154
 TQpSolverBase.h:155
 TQpSolverBase.h:156
 TQpSolverBase.h:157
 TQpSolverBase.h:158
 TQpSolverBase.h:159
 TQpSolverBase.h:160
 TQpSolverBase.h:161
 TQpSolverBase.h:162
 TQpSolverBase.h:163
 TQpSolverBase.h:164
 TQpSolverBase.h:165
 TQpSolverBase.h:166
 TQpSolverBase.h:167
 TQpSolverBase.h:168
 TQpSolverBase.h:169
 TQpSolverBase.h:170
 TQpSolverBase.h:171
 TQpSolverBase.h:172
 TQpSolverBase.h:173
 TQpSolverBase.h:174
 TQpSolverBase.h:175
 TQpSolverBase.h:176
 TQpSolverBase.h:177
 TQpSolverBase.h:178
 TQpSolverBase.h:179