/*
    Copyright (C) 2011 Brendon J. Brewer
    This file is part of DNest, the Diffusive Nested Sampler.

    DNest 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, either version 3 of the License, or
    (at your option) any later version.

    DNest 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 DNest.  If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef _Level_
#define _Level_

#include "LikelihoodType.h"
#include <vector>
#include <ostream>

namespace DNest
{
	class Model;

	class Level
	{
		private:
			double logX;
			LikelihoodType cutoff;

			unsigned long accepts;
			unsigned long tries;
			unsigned long visits;
			unsigned long exceeds;

		public:
			Level(double logX, const LikelihoodType& cutoff);
			Level(double logX, double logl, double tieBreaker);
			LikelihoodType getCutoff() const;
			double getLogX() const;
			unsigned long getTries() const;
			void incrementVisits(bool incrementExceeds);
			void incrementTries(bool accepted);

			static void recalculateLogX(std::vector<Level>& levels, int regularisation);
			static void renormaliseVisits(std::vector<Level>& levels, int regularisation, bool doExceeds);

		friend bool operator < (const Level& level, const Model* model);
		friend std::ostream& operator << (std::ostream& out, const Level& level);
	};

}
#endif

