/*Header file of the PStep_TreeNode class

Implementation can be found in PStep_TreeNode.cpp.

This class represents a node in the search tree used for solving the CVRP using p-steps.

*/

#ifndef _PSTEPTREENODE_H
#define _PSTEPTREENODE_H

#include <list>
#include "PStep_EdgeFlowCut.h"

//Class used to repesent a node of PStep_Tree
class PStep_TreeNode{

public:
	//Node ID, -1 signifies that this node is not used
	//RootNode has ID 1
	int ID;
	//Parent ID, -1 signifies no parent
	int ParentID;
	//Depth of the node in the tree, -1 signifies that this node is not used
	//RootNode has Depth 1
	int Depth;
	//LB obtained by the parent
	double ParentLB;

	//Number of locations
	short int NumberOfLocations;

	//Usage arrays:
	//Array indicating which edges are still in use
	//EdgeInUse[(j-1)(j)/2+i] indicates whether edge (i,j), i<j, is still in use.
	//Keep in mind that the edges of the depot could be selected with value 2, indicating a return trip.
	//Here i=0 corresponds to the depot.
	bool *EdgeInUse;

	//Cuts that are valid for this node and its children:
	//Cuts represented by nodes and limited by an...
	//...lower bound
	std::list<PStep_EdgeFlowCut> EdgeFlowCuts_ByNodes_LB;
	//...equality
	std::list<PStep_EdgeFlowCut> EdgeFlowCuts_ByNodes_EQ;
	//...upper bound
	std::list<PStep_EdgeFlowCut> EdgeFlowCuts_ByNodes_UB;
	//Cuts represented by edges and limited by an...
	//...lower bound
	std::list<PStep_EdgeFlowCut> EdgeFlowCuts_ByEdges_LB;
	//...equality
	std::list<PStep_EdgeFlowCut> EdgeFlowCuts_ByEdges_EQ;
	//...upper bound
	std::list<PStep_EdgeFlowCut> EdgeFlowCuts_ByEdges_UB;

	//Constructor functions:
	//------------------------------------------------------------------------------------

	//Default Constructor
	PStep_TreeNode();

	//Copy Constructor
	PStep_TreeNode(const PStep_TreeNode &OriginalPStep_TreeNode);

	//Constructor used for basic initialization.
	//It sets the parameters equal to the input and initializes edge usage array as true for all entries.
	PStep_TreeNode(int NewID, int NewParentID, int NewDepth, double NewParentLB, short int NewNumberOfLocations);

	//Operator functions:
	//------------------------------------------------------------------------------------

	//Assignment operator
	PStep_TreeNode operator=(PStep_TreeNode OriginalPStep_TreeNode);

	//Destructor functions
	//------------------------------------------------------------------------------------

	//Default destructor
	~PStep_TreeNode();

	//Print functions
	//-----------------------------------------------------------------------------------

	//Print EdgeInUse
	void PrintEdgeInUse();

private:
	//Auxiliary functions
	//------------------------------------------------------------------------------------

	//Empty all entries
	void EmptyNode();

	//Copy all entries
	//IMPORTANT: it is assumed that the current node is empty!
	//It is also assumed that NumberOfCustomers corresponds to the array lengths
	void CopyEmptyAssumed(const PStep_TreeNode &OriginalDTWVARPTreeNode);

};

#endif