//----------------------------------------------------------------------------//
//    module ThrUseModel.h                                                    //
//                                                                            //
//    Thread function: Use given model (TCluster) with given parameters       //
//    (TParameter) to predict the unknown ouput values using only the inputs  //
//    for a given TData object. Employs the class TPrediction.                //
//                                                                            //                                                                            //
//    copyright (c) 2003 by Lars Haendel                                      //
//    home: www.newty.de                                                      //
//                                                                            //
//    This program is free software; you can redistribute it and/or modify    //
//    it under the terms of the GNU General Public License as published by    //
//    the Free Software Foundation as version 2 of the License.               //
//                                                                            //
//    This program is distributed in the hope that it will be useful,         //
//    but WITHOUT ANY WARRANTY; without even the implied warranty of          //
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           //
//    GNU General Public License for more details.                            //
//                                                                            //
//    You should have received a copy of the GNU General Public License       //
//    along with this program; if not, write to the Free Software             //
//    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               //
//                                                                            //
//----------------------------------------------------------------------------//

#ifndef ThrUseModelH
#define ThrUseModelH


#include <Classes.hpp>


//---------------------------------------------------------------------------
#include <iostream>           // due to:  ofstream


#include "FMain.h"            //          TFMain
#include "prediction.h"       //          TPrediction
#include "lossfunc.h"         //          TLossFucntion


//----------------------------------------------------------------------------------------------------------------------
// thread object: Calls TPrediction::Predict() in its Execute function  
class ThrUseModel : public TThread
{
private:
   void __fastcall Execute();

   TFMain*           main;             // main (parent) form
   TData*            data;             // data object whose Load function will be executed
   ofstream*         file;             // simulation output file
   TLossFunction*    loss;             // loss object
   TCluster*         model;            // model to be passed to prediction object
   const TParameter* para;             // parameters
   TPrediction*      prd;              // prediction object

   bool f_IsWithOutput;

   void __fastcall MessageBox();       // display error message
   char szText[256];                   // error message text


   void __fastcall OnFinish(TObject*); // call when finished

public:

   // constructor
   __fastcall ThrUseModel(bool CreateSuspended, TFMain*const& _main, TData*const& _data,
         const bool& _f_IsWithOutput, TLossFunction*const& loss, TCluster*const& _model,
         TParameter*const& _para, ofstream*const& _file);

   const int Progress() const;
};
#endif