示例#1
0
/// Implementation of the constraints computation.
/// (Wraps over the original implementation with de-rotated input)
void rotated::compute_constraints_impl(constraint_vector &c, const decision_vector &x) const
{
	m_original_problem->compute_constraints(c, derotate(x));
}
示例#2
0
int TCH(float* inputReal,float* inputImag, int input_pos_tch , int BSIC_NUM , int my_local_FN , TCHStruct* pTCHInstant){
	
	int ovs = 2;
	int framelen = 2500;
	//偷帧标志,等于4或-4
	int stealFlag = 0;
	
	pTCHInstant->pos_tch = input_pos_tch;
	
	pTCHInstant->counter++;

	for(int indexn = 0 ; indexn < 4 ; indexn++) {
		
		float* y_chReal = inputReal + pTCHInstant->pos_tch;
		float* y_chImag = inputImag + pTCHInstant->pos_tch;
		int Tail_Length = 3;
		int Guard_Length = 4;
		int Code_Length = 58;
		int Burst_Length = 156;
		int TS_index = (BSIC_NUM & 0x07) + 1;
		
		int centre_N = 16;
		int train_offset = 3+57+1+5;
		float* TS_trainReal = tchTS[TS_index - 1] + 5;
		float* TS_trainImag = tchTS_Imag;
		float centre_trainReal[16];
		float centre_trainImag[16];
		
		rotate(TS_trainReal, TS_trainImag , 16 , train_offset ,centre_trainReal,centre_trainImag);
		
		float train_addReal[32];
		float train_addImag[32];
		
		
		for(int index =0 ;index < 16;index ++){
			train_addReal[index * 2] = centre_trainReal[index];
			train_addImag[index * 2] = centre_trainImag[index];
			train_addReal[index * 2 + 1] = 0;
			train_addImag[index * 2 + 1] = 0;
		}
		
		int GD = 0;
		GD = train_offset;
		int Cor_Length = 17;
		int ii = 0;
		float syncReal[17];
		float syncImag[17];
		
		//DumpFile(y_chReal,"y_chReal", 312);
		//DumpFile(y_chImag,"y_chImag", 312);

		//DumpFile(train_addReal,"train_addReal", 32);
		//DumpFile(train_addImag,"train_addImag", 32);

		int jj = 0;
		for(int offset = GD * 2 + 1; offset < GD*2 + 18;offset++) {
			syncReal[ii] = 0;
			syncImag[ii] = 0;
			
			for(jj = offset;jj< offset + centre_N * ovs ; jj++) {
				syncReal[ii] += y_chReal[jj-1] * train_addReal[jj-offset] + 
					y_chImag[jj-1] * train_addImag[jj-offset];
				
				syncImag[ii] += -y_chReal[jj-1] * train_addImag[jj-offset] + 
					y_chImag[jj-1] * train_addReal[jj-offset];
			}
			syncReal[ii] = syncReal[ii]/16.0;
			syncImag[ii] = syncImag[ii]/16.0;
			ii++;
		}
		
		//DumpFile(syncReal,"syncReal", 17);
		//DumpFile(syncImag,"syncImag", 17);

		int locmaxmagn_expect = 9;
		float tempsum[9];
		
		float maxaa = 0;
		int maxbb = 0;
		
		for(int offset = 0 ; offset <9 ;offset++){
		
			tempsum[offset] = 0;
			for(int index = locmaxmagn_expect-offset-1 ; index < locmaxmagn_expect-offset+8 ; index++){
				tempsum[offset] += syncReal[index] * syncReal[index] +
					syncImag[index] * syncImag[index];
			}
			if (tempsum[offset] > maxaa){
				maxaa = tempsum[offset];
				maxbb = offset;
			}
		}

		maxbb++;

		int start_window = locmaxmagn_expect - (maxbb - 1);
	
	
		int window_size = 9;
	
		float h_esitmate_temp0Real[9];
		float h_esitmate_temp0Imag[9];
	
		for (int index = 0 ; index < window_size ;index++){
			h_esitmate_temp0Real[index] = syncReal[start_window + index - 1];
			h_esitmate_temp0Imag[index] = syncImag[start_window + index - 1];
		}

		//DumpFile(h_esitmate_temp0Real,"h_esitmate_temp0Real", 9);
		//DumpFile(h_esitmate_temp0Imag,"h_esitmate_temp0Imag", 9);

		int first_path = 0;
		first_path = Guard_Length * 2 + 1 - maxbb + 1;
		
		float* py_chReal_selectReal = 0;
		float* py_chImag_selectImag = 0;
		py_chReal_selectReal = y_chReal + first_path - 1 ;
		py_chImag_selectImag = y_chImag + first_path - 1;
	
		////DumpFile(py_chReal_selectReal,"py_chReal_selectReal", 312);
		////DumpFile(py_chImag_selectImag,"py_chImag_selectImag", 312);

		float mf_output_tempReal[315];
		float mf_output_tempImag[315];
	
		for(int index = 0; index < 315 ; index++) {
			mf_output_tempReal[index] = 0;
			mf_output_tempImag[index] = 0;
		
			int shiftA =  (- 8 + index) ;
			int shiftB = 0 ; 
			for(shiftB = 0 ; shiftB < 9 ; shiftB++,shiftA++){			
				if ((shiftA >= 0) && (shiftA < 307 )){
					mf_output_tempReal[index] += h_esitmate_temp0Real[shiftB] * py_chReal_selectReal[shiftA] + 
						h_esitmate_temp0Imag[shiftB] * py_chImag_selectImag[shiftA];
					mf_output_tempImag[index] += h_esitmate_temp0Real[shiftB] * py_chImag_selectImag[shiftA] -
						h_esitmate_temp0Imag[shiftB] * py_chReal_selectReal[shiftA];
				}			
			}
		}

		//DumpFile(mf_output_tempReal,"mf_output_tempReal", 315);
		//DumpFile(mf_output_tempImag,"mf_output_tempImag", 315);


		float sample_yReal[156];
		float sample_yImag[156];
		for(int index = 0; index < 156 ; index++) {
			sample_yReal[index] = mf_output_tempReal[8 + index * 2];
			sample_yImag[index] = mf_output_tempImag[8 + index * 2];
		}

		//DumpFile(sample_yReal,"sample_yReal", 156);
		//DumpFile(sample_yImag,"sample_yImag", 156);

		float derotated_yReal[156];
		float derotated_yImag[156];
		derotate(sample_yReal , sample_yImag , 156 , 0 , derotated_yReal 
			,derotated_yImag);

		//DumpFile(derotated_yReal,"derotated_yReal", 156);
		//DumpFile(derotated_yImag,"derotated_yImag", 156);

		float sparamReal[17];
		float sparamImag[17];
	
		for(int index = 0; index < 17 ; index++) {
			sparamReal[index] = 0;
			sparamImag[index] = 0;
		
			int shiftA =  (- 8 + index) ;
			int shiftB = 0 ; 
			for(shiftB = 0 ; shiftB < 9 ; shiftB++,shiftA++){			
				if ((shiftA >= 0) && (shiftA < 9 )){
					sparamReal[index] += h_esitmate_temp0Real[shiftB] * h_esitmate_temp0Real[shiftA] + 
						h_esitmate_temp0Imag[shiftB] * h_esitmate_temp0Imag[shiftA];
					sparamImag[index] += h_esitmate_temp0Real[shiftB] * h_esitmate_temp0Imag[shiftA] -
						h_esitmate_temp0Imag[shiftB] * h_esitmate_temp0Real[shiftA];
				}			
			}
		}

		//DumpFile(sparamReal,"sparamReal", 17);
		//DumpFile(sparamImag,"sparamImag", 17);

	
		float sparamD2Real[5] ;
		float sparamD2Imag[5] ;
	
		for(int index = 0; index < 5 ; index++) {
			sparamD2Real[index] = sparamReal[8 + index * 2];
			sparamD2Imag[index] = -sparamImag[8 + index * 2];
		}
		float sparam_derotateReal[5] ;
		float sparam_derotateImag[5] ;
	
		derotate(sparamD2Real , sparamD2Imag , 5 , 0 , sparam_derotateReal 
			,sparam_derotateImag);
	
		//DumpFile(sparam_derotateReal,"sparam_derotateReal", 5);
		//DumpFile(sparam_derotateImag,"sparam_derotateImag", 5);

		//viterbi_trellis TBD
		float result_hd[148];
		// result_hd = viterbi_trellis(sparam_derotate, derotated_y, 148+4);
		viterbi_trellis(sparam_derotateReal,sparam_derotateImag,derotated_yReal,tchb_matrix,result_hd);

		//DumpFile(result_hd,"result_hd", 148);
	
		float isicReal[9];
		float isicImag[9];
		isicReal[4] = 0;
		isicImag[4] = 0;
	
		for(int index = 5; index <9 ; index++) {
			isicReal[index] = sparam_derotateReal[index-4];
			isicImag[index] = sparam_derotateImag[index-4];
		}
		for(int index = 0; index <5 ; index++) {
			isicReal[index] = isicReal[8 - index];
			isicImag[index] = -isicImag[8 - index];
		}	
		//isi_cancelator TBD	
		float result_sd[148];
		float result_sdImag[148];
	
		//DumpFile(isicReal,"isicReal", 9);
		//DumpFile(isicImag,"isicImag", 9);

		isi_cancelator(result_hd, derotated_yReal,derotated_yImag, isicReal,isicImag,result_sd,result_sdImag);
	
		//DumpFile(result_sd,"result_sd", 148);
		//DumpFile(result_sdImag,"result_sdImag", 148);

		//
		float noise_averge = 0.0f;
		float tmp = 0.0f;

		for(int index = 0; index <148 ; index++) {
			tmp = fabs(result_sd[index]) - sparamD2Real[0];
			noise_averge += tmp * tmp / 148.0f;
		}	
		float SNR = 0;
		SNR = sparamD2Real[0] * sparamD2Real[0] / noise_averge;
		// SNR estimation
		if (SNR < 6){
			//printf("TCH :%f %d\n",SNR,pTCHInstant->counter);
		}

		for(int index = 0 ; index < 57 ; index++){
			pTCHInstant->burst_tch[indexn][index] = -result_sd[index+3];
		}
		
		for(int index = 0 ; index < 57 ; index++){
			pTCHInstant->burst_tch[indexn][index + 57] = -result_sd[index+88];
		}
		if((result_sd[57 +3] > 0) && (result_sd[57 + 88] < 0))
		{
			stealFlag++;
		}
	
		//DumpFile(pTCHInstant->burst_tch[indexn],"result_tch", 114);

		pTCHInstant->pos_tch = pTCHInstant->pos_tch + framelen;
		
	}
	
	
	return stealFlag;
}
示例#3
0
/// Implementation of the objective function.
/// (Wraps over the original implementation with de-rotated input)
void rotated::objfun_impl(fitness_vector &f, const decision_vector &x) const
{
	m_original_problem->objfun(f, derotate(x));
}