/*Implementation of PStep_ColumnGenerator.h

It contains the member functions of PStep_ColumnGenerator11

*/

#include "PStep_ColumnGenerator.h"

//PStep_ColumnGenerator11:
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

//Generate columns
//------------------------------------------------------------------------------------

//Apply local search first, if it fails apply decremetal state-space relaxation.
//In this case, first aply heuristic labeling with a limited number of arcs and not
//considering reachability when checking dominance. If that fails apply exact labeling.
void PStep_ColumnGenerator11::GenerateColumns(){

	//Obtain the number of p-steps currently added
	int NumberOfCurrentPStepsBefore = AlgorithmMembers.NumberOfCurrentPSteps;

	//Apply column generator 2, local search.
	GenerateColumns2();

	//Check if p-steps are added
	if (AlgorithmMembers.NumberOfCurrentPSteps == NumberOfCurrentPStepsBefore){

		//Reinitialize the decremental state-space information, if required
		if (AlgorithmMembers.DSSRUsed && AlgorithmMembers.AlgorithmSettings.DSSRReset == 3){
			ResetDSSRNeighbourhoods();
		}

		//Initialize the decremental state-space relaxation loop
		RerunRequired = true;

		//Store the original setting os DoNotCheckReachability
		bool OriginalDoNotCheckReachability = DoNotCheckReachability;
		//Update the column generator setting to only use a limited number of arcs
		DoNotCheckReachability = true;
		//Resolve the pricing problem as long as RerunRequired is true
		while (RerunRequired){

			//Generate columns using limited arcs and not checking reachability
			GenerateColumns3();

		}
		/*
		//Check if p-steps are added
		if (AlgorithmMembers.NumberOfCurrentPSteps == NumberOfCurrentPStepsBefore){
			//Heuristic labeling failed, now consider all arcs
			
			//Initialize the decremental state-space relaxation loop
			RerunRequired = true;
			
			//Resolve the pricing problem as long as RerunRequired is true
			while (RerunRequired){

				//Generate columns while not checking reachability
				GenerateColumns1();

			}
			*/
			//Restore the original setting of DoNotCheckReachability
			DoNotCheckReachability = OriginalDoNotCheckReachability;
			/*
			//Check if p-steps are added
			if (AlgorithmMembers.NumberOfCurrentPSteps == NumberOfCurrentPStepsBefore){
				//Heuristic labeling failed, now check reachability but only consider a limited set of arcs

				//Initialize the decremental state-space relaxation loop
				RerunRequired = true;

				//Resolve the pricing problem as long as RerunRequired is true
				while (RerunRequired){

					//Generate columns while only considering a limited set of arcs
					GenerateColumns3();

				}
				*/
				//Check if p-steps are added
				if (AlgorithmMembers.NumberOfCurrentPSteps == NumberOfCurrentPStepsBefore){
					//Heuristic labeling failed, apply exact labeling
					
					//Initialize the decremental state-space relaxation loop
					RerunRequired = true;

					//Resolve the pricing problem as long as RerunRequired is true
					while (RerunRequired){
						
						//Generate columns
						GenerateColumns1();

					}

				}

			/*}

		}
		else{
			//Restore the original setting of DoNotCheckReachability
			DoNotCheckReachability = OriginalDoNotCheckReachability;
		}*/

	}

}