/*
    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 _DNestSampler_
#define _DNestSampler_

#include "Model.h"
#include "DNestOptions.h"
#include "Level.h"
#include <vector>
#include <string.h>

namespace DNest
{

	class DNestSampler
	{
		private:
			DNestOptions options;
			std::vector<Model*> theModels;
			std::vector<int> theIndices;

			std::vector<Level> theLevels;
			std::vector<LikelihoodType> loglKeep;

			unsigned long step;

			static const std::string sampleFile;
			static const std::string sampleInfoFile;
			static const std::string levelsFile;
			static const std::string optionsFile;

			bool initialised;
			void deleteModel();

			// Declared private, of no use
			DNestSampler(const DNestSampler& other);
			DNestSampler& operator = (const DNestSampler& other);

		public:
			DNestSampler(const Model* exampleModel);
			~DNestSampler();

			void initialise(); // Set all models from prior
			void run();
			void update();
			void updateModel(int which);
			void updateIndex(int which);
			void addLevel(); // Adds a level, only if appropriate
			double logPush(int index) const;
			void saveLevels() const;
			void saveSample(int which) const;
	};

}

#endif

