/*****************************************************************//**
 * \file   Constraint.h
 * \brief  A generic constraint interface to store the specific constraint wheither it is a branching constraint or a cut constraint.
 *
 * \author Matteo Petris
 * \date   March 2023
 *********************************************************************/
#ifndef STABILITYCONSTRAINT_H
#define STABILITYCONSTRAINT_H

#include "Constraint.h"

template<class Type>
class StabilityConstraint : public Constraint<Type> {

protected:

	int subsetPosition;
	vector<int> subset;
	string subsetToString;

public:
	/**
	 * Constructor by default.
	 *
	 */
	StabilityConstraint() :Constraint<Type>(), subset() {
	}


	/**
	 * Constructor with the left hand side, the right hand side and the operator of the constraint.
	 *
	 * \param variables_indexes: vector<int>&
	 * \param rhs: double
	 * \param _operator: const string&
	 */
	StabilityConstraint(double rhs, const string& _operator, const int& subsetPosition, const vector<int>& subset, const string& name = "") :
		Constraint<Type>(rhs, _operator, name), subsetPosition(subsetPosition), subset(subset) {
		for (int i = 0; i < this->subset.size(); i++) {
			subsetToString += "_" + to_string(this->subset.at(i));
		}
	}

	/**
	 * Destructor.
	 *
	 */
	virtual ~StabilityConstraint() {
	}


	/**
	 * Get method of items.
	 *
	 * \return items: const pair<int, int>&
	 */
	const vector<int>& get_subset() const {
		return this->subset;
	}
	const string& get_subsetToString() const {
		return this->subsetToString;
	}

	string toString() const {
		string mystring = "STABILITY\t" + to_string(this->subsetPosition) + "\n";
		for (int i = 0; i < this->subset.size(); i++) {
			mystring += "\t" + to_string(this->subset.at(i)) + " ";
		}
		mystring += "\n";
		return mystring;
	}

	/**
	*  \brief	 Get a string for debug output.
	*  \param    out : ostream
	*  \param    constraint : const ArcBranchConstraint<Type>&
	*  \return   The stream with the message ID added : ostream
	*/
	friend ostream& operator<<(ostream& out, const StabilityConstraint<Type>& constraint) {
		out << constraint.to_string();
		return out;
	}
};
#endif //STABILITYCONSTRAINT_H
