⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sips.h

📁 一种OFDMA低复杂度的比例资源分配策略仿真程序,C语言编程的
💻 H
字号:
/***************************************************************************
Author: Ian C. Wong and Robert Mullenix   
Copyright (C) 2004   Ian C. Wong

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

You may reach the author at wongic@mail.utexas.edu.
Or visit his website at www.ece.utexas.edu/~iwong
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _TI_ENHANCED_MATH_H 1
#include <math.h>
#include <float.h>
#include <time.h>
#include "qsort.h"

//  Definitions

#define ever ;;
#define tot_Bandwidth 1000000		//  Total bandwidth for the transmitter
#define tot_Power 100				//  Total power available to the transmitter
#define N 64
#define p (float)tot_Power / (float)N
#define log2m 1.442695f
#define RAND_MAX_X_PT5 16383
#define RAND_MAX_X_PT8 26214
#define NUM_SAMP 100
#define NUM_USR 16
#define CLK_OVHD 661
#ifdef WIN32
	#define log2f(x) log(x)/log(2.0)
	#define CLK_OVHD 0
#endif
/*typedef struct { 
	int IDX;
	float SNR;
} */
typedef float SNRArray[N];
typedef int IDXArray[N];

//  Functions
void Sys_Init(int user, SNRArray *SNR, IDXArray *IDX, float *Proportionality, 
			  int *Shen_Assignment,int *Wong_Assignment, FILE *pFile);
//void Sys_Free(void);
void Shen_Challoc(SNRArray *SNR, IDXArray *IDX, int user, int *Shen_Assignment, 
				float *Proportionality, int *Hmin);
void Wong_Challoc(SNRArray *SNR, IDXArray *IDX, int user, int *Wong_Assignment, 
				float *Proportionality, int *Hmin);
//int Best_SNR(int k, int *Shen_Assignment, IDXArray *IDX, int *curIDX);
int Best_SNR(int *Assignment, int *Idx, int *curIDX);
int Best_user(int user, SNRArray *SNR, char *Exclude, int n);
int Worst_user(int user, float *Data_rate, float *Proportionality);
int Chan_gone();
int Shen_Palloc(int user, SNRArray *SNR, int *Shen_Assignment, 
				float *Data_rate, float *Proportionality, int *Hmin);
int Wong_Palloc(int user, SNRArray *SNR, int *Wong_Assignment, float *Data_rate, int *Hmin);
void set_params(int *Shen_Assignment, SNRArray *SNR, int user, float *Proportionality, 
		        int *Num_chan, int *Hmin, double *Wk, float *dk, float *ck);
/*void set_Wk(void);
void set_dk(int);
void set_ck(int);*/
float Newt_Raph(float guess, int user, float *ck, float *dk, float *fx);
float Pow_dist(int);
void UpdateDataRate();

//extern int user;							//  Number of users in system, K
//extern float sum;							//  Number of iterations used in the Newton-Raphson method
//extern float sum2;							//  Number of iterations used in the Newton-Raphson method
//extern float fx;							//  Solution of equation (17) in Shen's paper, with P1,tot guessed
//extern float dfx;							//  Soltuion to the derivative of equation (17) in Shen's paper, with P1, tot guessed
// extern unsigned int cnt_old, cnt_new, cnt_dchalloc, cnt_dpalloc;

//extern SNRArray *SNR;				//  KxN array of channel conditions
//extern IDXArray *IDX;
//extern int Assignment[N];
						   	//  N array for subcarrier assignment

//extern float *Bit_rate;					//  KxN array of bit rate for user k and subchannel n, rk,n					
//extern int *Num_chan;						//  K array of total number of channels assigned to kth user, Nk
//extern int *curIDX;						//  K array of starting index for search
//extern int *Hk1;							//  K array of indexes to lowest SNR for user k, Hk1
//extern float *Data_rate;					//  K array of data rate for kth user, Rk
//extern float Proportionality[16];					//  K array of proportionality constants for kth user, Gammak
//float *Proportionality;				//  K array of proportionality constants for kth user, Gammak
//extern double *Wk;							//  K array of constants based on SNR ratios, Wk
//extern float *ck;							//  K array of constants used in total power allocation, ck
//extern float *dk;							//  K array of constants used in total power allocation, dk
//extern float *User_pow;					//  K array of total power allocation for user k, Pk,tot (sum should equal tot_pow)

//extern int user_num[8];
//extern float aver_chal[8];
//extern float aver_pall[8];
//extern float aver_iter[8];
//extern float aver_datarate[8];

//extern int error;
//extern float tot_dr;
//extern float iter;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -