int	BDD_class::next_bit_layer(int depth){
	if((depth < BSD_variable_order_depth) ){
			if(!has_been_unfold[BSD_variable_order[depth]]){
				most_influence[depth] = BSD_variable_order[depth];
				has_been_unfold[most_influence[depth]]=1;
				cout<<most_influence[depth]<<endl;
				return  BSD_variable_order[depth];
			}
			else{
				;
			}
		return next_bit_layer_0(depth);
	}
	else{
		return next_bit_layer_0(depth);
	}
}


int	BDD_class::next_bit_layer_0(int depth){
		
	int	most_influence_next=0;
	int 	i,j,k;
	int	zz;
	int	zi;
	bool*	should_not_be_unfold = new bool [parameter_input_bit_width+1];
	random_device rd;	
	mt19937 gen(rd());

	for (zz=0;zz<parameter_input_bit_width+1;zz++){
		amount_turn[zz] = 0;
		should_not_be_unfold[zz] = 0;
	}
	long	parameter_sample_mul = 10;
			for (j=0;j<20;j++){
				parameter_sample_mul *= 10;
				if((parameter_sample_mul * (1-total_finish_weight/pow(2.0,20))) > 10000){
					break;
				}
			}
	int	BSD_samples_influence = BSD_samples_influence_max;
	for (zz=0;zz<1;zz++){
		if(depth < parameter_multi_output_index){
			break;
		}
		
		int	which_node_this_layer = 0;
		int	which_node_this_layer_sample = 0;
		int	which_node_this_layer_array[BSD_samples_influence];
		//#pragma omp parallel for
		for (int i=0;i<BSD_samples_influence;i++){
			int which_node_this_layer = gen()%BDD_width_each_layer[depth];
			for (j=0;j<parameter_input_bit_width;j++){
				int zi = 0;
				long randint;
				zi = j%30;
				if(zi == 0){
					randint = gen();
				}
				if(depth == 0){
					mask_input_data[i][j] = bool((randint >> (zi))%2);
				}
				else{
					if(has_been_unfold[j]){
						mask_input_data[i][j] = BDD_mask_this[which_node_this_layer].mask[j];
					}else{	
						mask_input_data[i][j] = bool((randint >> (zi))%2);		
					}
					
				}
			}	
			which_node_this_layer_array[i] = which_node_this_layer;
		}
		
		for (i=0;i<parameter_input_bit_width+1;i++){
			if(has_been_unfold[i] || should_not_be_unfold[i]){
				
			}else{
				#pragma omp parallel for
				for(int j=0;j<BSD_samples_influence;j++){
					bool* amount_turn_input_data_ij = new bool [parameter_input_bit_width+1];
					for(int k=0;k<parameter_input_bit_width;k++){
							amount_turn_input_data_ij[k] = mask_input_data[j][k];
					}
					amount_turn_input_data_ij[i] = !amount_turn_input_data_ij[i];
					bool amount_turn_output_data_ij = io_generator_single(amount_turn_input_data_ij,BDD[depth][which_node_this_layer_array[j]].which_bit_output);
					//bool amount_turn_output_data_ij = io_generator_single(amount_turn_input_data_ij,0);
					amount_turn_output_data[i][j] = amount_turn_output_data_ij;
					arr_delete(amount_turn_input_data_ij);
				}
			}
		}
		bool	finish_influence_sample = 0;
		for (i=0;i<parameter_input_bit_width;i++){
			if(has_been_unfold[i] || should_not_be_unfold[i]){
				amount_turn[i] = -1;	
			}else{
				for(j=0;j<BSD_samples_influence;j++){
					if(amount_turn_output_data[i][j] && !amount_turn_output_data[parameter_input_bit_width][j]){
						amount_turn[i] += 1;
					}
					else if(!amount_turn_output_data[i][j] && amount_turn_output_data[parameter_input_bit_width][j]){
						amount_turn[i] += 1;
					}
				}
				//USE_THIS:RANDOM
				//if(i<64)
					//amount_turn[i] = gen()%5;
				//else 
				//	amount_turn[i] = 0;
					
				if((amount_turn[i] > 40) && ((zz*BSD_samples_influence-amount_turn[i])>40)){
					finish_influence_sample = 1;
				}
				
			}
			//cout<<"bit "<<i<<"	amount turn:	"<<amount_turn[i]<<"	has been unfold	"<<has_been_unfold[i]<<"should not be unfold	"<<should_not_be_unfold[i]<<endl;
		}
		
		if(finish_influence_sample){
			cout<<"这一层排序的采样个数为："<<zz*BSD_samples_influence<<endl;
			break;
		}
	}
			cout<<"这一层排序的采样个数为："<<zz*BSD_samples_influence<<endl;
	double amount_turn_all = 0;
	double amount_turn_valid_bits = 0;
	int	amount_turn_static[parameter_input_bit_width];
	for (i=0;i<parameter_input_bit_width;i++){
		if(amount_turn[i]>((zz*BSD_samples_influence)/2.0)){
			amount_turn_static[i] = amount_turn[i];
		}else{
			amount_turn_static[i] = amount_turn[i];
		}
		if(amount_turn_static[i]>=1){
			amount_turn_all = amount_turn_all + max(1,amount_turn_static[i]);
			amount_turn_valid_bits = amount_turn_valid_bits + 1;
		}
	}
	double amount_turn_average = (amount_turn_all+1)/amount_turn_valid_bits;
	most_influence_next = max_element(amount_turn_static,amount_turn_static+parameter_input_bit_width) - amount_turn_static;	
	for (i=0;i<parameter_input_bit_width;i++){
		if(has_been_unfold[most_influence_next]){
			amount_turn_static[most_influence_next] = -10;
		}else{
			break;	//has_been_unfold[most_influence_next] = 1;
		}
		most_influence_next = max_element(amount_turn_static,amount_turn_static+parameter_input_bit_width) - amount_turn_static;
	}
	has_been_unfold[most_influence_next] = 1;
	double amount_turn_max_divide_average = amount_turn_static[most_influence_next]/amount_turn_average;
	double amount_turn_max_ratio = amount_turn[most_influence_next]/(zz+1);
	arr_delete(	should_not_be_unfold);
	
	return	most_influence_next;
};
