// FiniteTD.H; copyright by Susumu Katayama
// Logarithmic-time implementation of Temporal-difference learning (Katayama & Kobayashi 1999, Katayama 2000) with finite states.
// You may use this file within your personal use, provided that you leave these comment lines untouched.
// You may not redistribute this file without my permission if some parts have been changed (me = S. Katayama).

#include "FiniteTD.H"
#include <iostream>
istream &operator>>(istream &istr, FiniteTD &ftd) {
  istr >> ftd.size;
  ftd.ds.resize(ftd.size*2);
  vector<pair<double,double> >::iterator p = ftd.ds.begin(), pe = ftd.ds.end();
  for ( ; p!=pe; p++)
    istr >> p->first >> p->second;
  return istr >> ftd.prevV;
}
ostream &operator<<(ostream &ostr, const FiniteTD &ftd) {
  ostr << endl << ftd.size << endl;
  vector<pair<double,double> >::const_iterator p = ftd.ds.begin(), pe = ftd.ds.end();
  for ( ; p!=pe; p++)
    ostr << p->first << " " << p->second << endl;
  return ostr << ftd.prevV << endl;
}
