亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? placement.cpp

?? uploading the file , the system will delete the file when time expires
?? CPP
字號:
#include "placement.h"
#include "rand32.h"
#include <math.h>

Placement::Placement(Netlist * nl) {
  this->nl = nl;
  celln = new int[nl->nCells];
  x     = new int[nl->nCells];
  y     = new int[nl->nCells];
  serial= new int[nl->nCells];
  disqualified = new bool[nl->nCells];
}

Placement::~Placement() {
  if(celln!=NULL) delete celln;
  if(x!=NULL) delete x;
  if(y!=NULL) delete y;
  if(serial!=NULL) delete serial;
  if(disqualified!=NULL) delete disqualified;

}

Placement * Placement::Clone() {
	Placement * myClone = new Placement(nl);
	myClone->myFitness = myFitness;
	for(int i=0;i<nl->nCells;i++) {
		myClone->celln[i] = celln[i];
		myClone->x[i] = x[i];
		myClone->y[i] = y[i];
		myClone->serial[i] = serial[i];
	}

	return myClone;
}

bool Placement::IsCloneOf(Placement * p) {
	// two placements are clones iff
	// for indexes i and j:
	// serial[i] == p->serial[j] =>
	// celln[i]  == p->celln[j]
	// IE all serial/celln pairs are identical,
	// regardless of ordering
	int i,j;

	for(int ser=0;ser<nl->nCells;ser++) {
		// find the index in this that correponsds to ser

		for(i=0;i<nl->nCells;i++) {
			if(serial[i]==ser) break;
		}

		// find the index in p that corresponds to ser
		for(j=0;j<nl->nCells;j++) {
			if(p->serial[j]==ser) break;
		}
//		printf("Serial %i is at %i in A and %i in B\n",ser,i,j);

		if(!(celln[i]==p->celln[j])) {
			// at least one difference here!
			return false;
		}

	}

	return true;
}

bool Placement::Crossover(Placement * a, Placement * b) {

//	printf("Crossingover has been invoked...");
	int i;
	Placement * temp_p;

	// initialize this placement to -1, and the disqualification
	// variables in a and b to false
	for(i=0;i<nl->nCells;i++) {
		celln[i] = -1;
		serial[i] = i;
		a->disqualified[i] = false;
		b->disqualified[i] = false;
	}

//	printf("Variables initialized\n");

	// select first parent randomly
	if(rand()%2==0) {
		// 50% of the time select b as first parent (a)
		temp_p = a;
		a = b;
		b = temp_p;
//		printf("Swapping parents!\n");
	}

	int nth_ser;
	int cur_ser;
	int cellnum;
	bool exists_in_child;
	bool xyz;

	// start the cyclic exchange process
	int unassigned_cells = nl->nCells;
	while(unassigned_cells>0) {
		
//		printf("Starting loop, unassiged cells = %i\n",unassigned_cells);

		// select a serial number ser_i in A 
		// corresponding to an index i that is not disqualified:
		// that is: a->y[i] is not == -1
		nth_ser = randOnRange(0,unassigned_cells-1);

		// find the index (i) of the nth unassiged serial number
		// in a
		cur_ser = -1;
		for(i=0;i<nl->nCells;i++) {
			if(!a->disqualified[i]) cur_ser++;
			if(cur_ser==nth_ser) break;
		}

//		printf("Selecting index %i to start with\n",i);

		xyz = true;
		while(xyz) {

			// give cell at a[i] to child at serial from a[i]
			celln[a->serial[i]] = a->celln[i];

//			printf("Giving Cell %i to child at index/serial = %i\n",a->celln[i],a->serial[i]);

			// disqualify cell at index [i] in a and at same serial in B
			// disqualify cell in A:
			a->disqualified[i] = true;

			// disqualify cell in B:
			cur_ser = b->DisqualifyCell(a->serial[i]);

			// decrement count of unassigned cells
			unassigned_cells--;

//			printf("A[%i] and B[%i] have been disqualified\n",i,cur_ser);

			// try to find b->celln[cur_ser] in the child (me)
			exists_in_child = false;
			cellnum = b->celln[cur_ser];
			for(i=0;i<nl->nCells;i++) {
				if(celln[i]==cellnum) {
					// already exists in child
					exists_in_child = true;
					break;
				} 
			}

			if(exists_in_child) {
				// swap A & B
//				printf("Cell exists in child: cycle over: swapping\n");
				temp_p = a;
				a = b;
				b = temp_p;
				xyz = false;
			} else {
				// find i st a->celln[i] == cellnum
				for(i=0;i<nl->nCells;i++) {
					if(a->celln[i]==cellnum) break;
				}

//				printf("Cell not in child, now giving cell %i\n",a->celln[i]);

				xyz = true;
			}
		}

	}

	rePlace();

	return true;
}

int Placement::DisqualifyCell(int cellnum) {
	for(int i=0;i<nl->nCells;i++) {
		if(serial[i]==cellnum) {
			disqualified[i] = true;
			return i;
		}
	}

	return -1;
}

bool Placement::Invert(int a, int b) {
	// param check
	if(a<0||a>=nl->nCells) return false;
	if(b<0||b>=nl->nCells) return false;
	if(a>=b) return false;

	int temp;
	// a and b inclusively specify the inversion bounds
	while(a<b) {
		// invert a and b
		
		// invert celln
		temp = celln[a];
		celln[a] = celln[b];
		celln[b] = temp;

		// invert x
		temp = x[a];
		x[a] = x[b];
		x[b] = temp;

		// invert y;
		temp = y[a];
		y[a] = y[b];
		y[b] = temp;

		// invert serial number
		temp = serial[a];
		serial[a] = serial[b];
		serial[b] = temp;

		a++;
		b--;
	}

	return true;

}

bool Placement::Mutate(int a, int b) {
	// check params
	if(a<0||a>=nl->nCells) return false;
	if(b<0||b>=nl->nCells) return false;
	if(a==b) return false;

	// swap the chromosomal positions of A and B,
	// then recalculate x & y positions of every cell
//	printf("Mutating cells %i and %i\n",celln[a]+1,celln[b]+1);

	int temp = celln[b];
	celln[b] = celln[a];
	celln[a] = temp;

//	temp = serial[b];
//	serial[b] = serial[a];
//	serial[a] = temp;

	rePlace();

	return true;
}

void Placement::Randomize() {
  // generate a random placement--this amounts to a
  // random sequence of genes, AKA a random ordering
  // of the cells
	int i;
  // use celln as assignment space--initialize to -1
  // use x as temporary space--initialize to cell #
	for( i=0;i<nl->nCells;i++) {
		x[i] = i;
		serial[i] = i;
	}

	// assign slots randomly
	int j,index;
	int cell;

	for(i=0;i<nl->nCells;i++) {
		cell = randOnRange(0,nl->nCells-i-1);
		
		// find the jth cell
		j = -1;
		index = -1;
		while(j!=cell) {
			index++;

			// skip all -1's
			while(x[index]==-1) 
				index++;

			// index points to first non- -1 entry, aka
			// the jth non- -1 entry
			j++;
		}

		celln[i] = x[index];
		x[index] = -1;
	}

	rePlace();


}

void Placement::rePlace() {
	// do the bookkeeping to assign x & y

	// NEXT OPEN SPOT
	int x_pos = 0;
	int y_pos = 0;

	// CURRENT ROW'S LENGTH
	int rowlen = 0;
	int i;

	for(int j=0;j<nl->nCells;j++) {
		// find the index i corresponding to serial number j
		i = 0;
		while(serial[i]!=j) i++;

		// i now is the index correpsonding to the current serial number
		// check to see if current cell will fit on current row
		if(rowlen+nl->cell_widths[celln[i]]<=nl->nRowMax) {
			// the cell won't fit on the current row
			x[i] = x_pos;
			y[i] = y_pos;

			// compute next open spot
			x_pos = x_pos + nl->cell_widths[celln[i]];

			// y_pos is unchanged
			rowlen += nl->cell_widths[celln[i]];
		} else {
			// the cell will not fit on the current row

			// place cell on next row
			y_pos = y_pos + nl->cell_height + nl->channel_height;
			
			x[i] = 0;
			y[i] = y_pos;

			rowlen = nl->cell_widths[celln[i]];

			x_pos = rowlen;
		}
	}
}

void Placement::dump(FILE * file) {
    int i,j,printed,printed_width;
	int last_y = 0;
	int size = nl->nCells;
	
	// unit size
	double unit_size = 75.0 / nl->nRowMax ;

	for(i=0;i<size;i++) {
		// i is the current cell we're printing
		for(j=0;j<size;j++) {
			// j is where we're looking for i
			if(serial[j]==i) break;
		}

		if(y[j]!=last_y) {
			last_y = y[j];
			fprintf(file,"\n");
		}

		// the cell's data is at celln[j], x[j], etc...

		// figure out how much space each cell can occupy
		printed_width = (int) (unit_size * nl->cell_widths[celln[j]]);
		printed = fprintf(file,"<");
		while(printed<printed_width/2) printed+=fprintf(file,"-");
		printed += fprintf(file,"%i",celln[j]+1);
		while(printed+1<printed_width) printed+=fprintf(file,"-");
		fprintf(file,">");

	}

	fprintf(file,"\n");

}

void Placement::dumpLiteral(FILE * file) {
	int i;
	for( i=0;i<nl->nCells;i++) {
		fprintf(file,"%i\t",celln[i]+1);
	}

	fprintf(file,"\n");
	
	for( i=0;i<nl->nCells;i++) {
		fprintf(file,"%i\t",x[i]);
	}

	fprintf(file,"\n");

	for( i=0;i<nl->nCells;i++) {
		fprintf(file,"%i\t",y[i]);
	}

	fprintf(file,"\n");

	for( i=0;i<nl->nCells;i++) {
		fprintf(file,"%i\t",serial[i]);
	}

	fprintf(file,"\n");
}

#define HORIZ_WEIGHT   1
#define VERT_WEIGHT    1

double Placement::Fitness() {
	// since this implementation assumes nothing about the
	// I/O layout of blocks, assume the average-case I/O placement--
	// that is, all connections go to the geographic middle of
	// of a given cell

	// ASSUME additional weight of hoziontal nets is HORIZ_WEIGHT
	// ASSUME additional weight of vert nets is VERT_WEIGHT

	// fitness is just the reciprical of the total weighted manhattan
	// interconnect span of all nets
	long interconnect = 0;
	int leftmost,rightmost,topmost,bottommost,span;

	int x_eff, y_eff;

	// find the weighted manhattan interconnect span of each net
	for(int net=0;net<nl->nNets;net++) {
		leftmost = topmost = 0x7FFFFFFF;
		rightmost = bottommost = -1;
		for(int cell=0;cell<nl->nconnections[net];cell++) {
			// the coordinates of the center of a cell is given by
			// x = (x_cell + cell_width) / 2
			// y = y_cell + CELL_HEIGHT / 2

			x_eff = (x[cell]+nl->cell_widths[cell]) >> 1;
			y_eff =  y[cell] + ( nl->cell_height >> 1 );

			// check superlatives
			
			// if left of leftmost
			if(x_eff<leftmost) leftmost = x_eff;

			// if right of rightmost
			if(x_eff>rightmost) rightmost = x_eff;

			// if below bottommost
			if(y_eff>bottommost) bottommost = y_eff;

			// if above topmost
			if(y_eff<topmost) topmost = y_eff;
		}
		span = HORIZ_WEIGHT * (rightmost-leftmost) +
			   VERT_WEIGHT  * (bottommost-topmost);

		// weight according to net weight
		span *= nl->net_weights[net];

		interconnect += span;

	}


	return 1.0 / interconnect;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产尤物一区二区| 国产91精品一区二区麻豆亚洲| 欧美成人vr18sexvr| 91丨九色丨蝌蚪丨老版| 视频一区二区三区中文字幕| 国产精品对白交换视频| 日韩一区二区三区电影 | 94-欧美-setu| 国产精品一区免费在线观看| 婷婷国产在线综合| 一区二区在线电影| 国产欧美一区二区精品性色超碰 | jlzzjlzz欧美大全| 国产又黄又大久久| 免费成人性网站| 亚洲www啪成人一区二区麻豆| 亚洲视频一二三区| 国产欧美日韩卡一| 久久亚洲欧美国产精品乐播| 欧美专区日韩专区| 91视频一区二区| 成人小视频免费在线观看| 国产一区二区在线观看免费| 蜜桃久久久久久久| 日本欧美加勒比视频| 亚洲成人精品一区| 亚洲国产一区二区三区| 一区二区三区**美女毛片| 亚洲欧美自拍偷拍| 亚洲国产经典视频| 国产精品色婷婷| 国产精品麻豆一区二区| 国产精品视频麻豆| 国产精品卡一卡二| 亚洲欧洲日产国码二区| 国产精品成人一区二区艾草| 国产精品狼人久久影院观看方式| 亚洲国产精品激情在线观看| 国产欧美日韩精品一区| 国产精品色眯眯| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 久久99久久99小草精品免视看| 一区二区三区四区精品在线视频 | 日韩欧美不卡一区| 欧美大胆人体bbbb| 精品国偷自产国产一区| 精品成人免费观看| 精品电影一区二区| 久久久精品影视| 国产欧美精品一区| 国产精品久久毛片a| 亚洲人成精品久久久久| 亚洲激情图片qvod| 天堂影院一区二区| 麻豆国产91在线播放| 国产综合色视频| 成人免费福利片| 欧美性猛交xxxxxx富婆| 91麻豆精品国产| 久久日韩精品一区二区五区| 国产精品久久久久aaaa| 亚洲综合区在线| 日产国产高清一区二区三区| 国内成+人亚洲+欧美+综合在线| 国产成人aaa| 91国在线观看| 日韩一级二级三级| 久久久精品国产99久久精品芒果| 国产精品国产三级国产有无不卡 | 欧美成人精精品一区二区频| 亚洲国产精品av| 亚洲国产裸拍裸体视频在线观看乱了| 婷婷综合另类小说色区| 久久超级碰视频| 91视视频在线观看入口直接观看www | 99国产精品久久| 欧美精品777| 欧美国产一区二区在线观看| 亚洲已满18点击进入久久| 久久精品国产久精国产| 99久久精品国产网站| 91精品欧美综合在线观看最新 | 爽好久久久欧美精品| 风间由美一区二区三区在线观看| 色久优优欧美色久优优| 日韩丝袜情趣美女图片| 国产精品福利在线播放| 调教+趴+乳夹+国产+精品| 国产成人综合亚洲91猫咪| 在线观看视频一区| 久久久精品免费观看| 亚洲成av人片一区二区| 国产99精品国产| 欧美丰满一区二区免费视频| 国产精品理论在线观看| 美女视频黄a大片欧美| 一本到高清视频免费精品| 精品久久久久一区| 亚洲韩国精品一区| 一本一道综合狠狠老| 久久综合狠狠综合| 午夜日韩在线电影| 99久免费精品视频在线观看 | 亚洲最快最全在线视频| 国产一区999| 宅男噜噜噜66一区二区66| 亚洲视频免费在线| 国产精品主播直播| 日韩视频一区二区三区在线播放| 亚洲欧洲综合另类在线| 国产不卡免费视频| 精品国产污网站| 日韩电影网1区2区| 91精彩视频在线观看| 国产精品免费人成网站| 国产美女娇喘av呻吟久久| 欧美一区在线视频| 亚洲成精国产精品女| 91亚洲男人天堂| 国产精品午夜在线观看| 国产精品亚洲成人| 2021久久国产精品不只是精品| 日韩福利电影在线观看| 欧美日韩一区二区三区免费看| 亚洲天堂精品在线观看| caoporen国产精品视频| 国产精品国产三级国产三级人妇| 韩日av一区二区| 精品欧美一区二区三区精品久久| 精品在线播放午夜| 亚洲免费观看高清完整版在线| 成人综合婷婷国产精品久久蜜臀| 26uuu精品一区二区在线观看| 日本女优在线视频一区二区| 欧美精品1区2区3区| 婷婷久久综合九色综合伊人色| 欧美日韩视频在线第一区| 午夜精品久久久久影视| 欧美福利一区二区| 五月综合激情婷婷六月色窝| 这里是久久伊人| 久久99精品久久久久久动态图| 日韩一区二区精品葵司在线| 久久精品国产一区二区三| 日韩一级片网址| 精品一区二区在线观看| 国产欧美一区二区精品婷婷 | 在线免费亚洲电影| 亚洲va欧美va天堂v国产综合| 欧美日韩一本到| 麻豆精品久久久| 久久蜜桃av一区二区天堂| 成人免费高清视频在线观看| 亚洲天堂av一区| 欧美日韩精品一区二区在线播放| 婷婷综合另类小说色区| 精品国产一区二区三区忘忧草| 国产又粗又猛又爽又黄91精品| 国产精品免费人成网站| 在线视频一区二区三| 日韩福利视频网| 国产无遮挡一区二区三区毛片日本| 国产成人午夜99999| 亚洲视频图片小说| 欧美精品vⅰdeose4hd| 国内精品免费**视频| 亚洲欧洲美洲综合色网| 欧美三级一区二区| 久草精品在线观看| 国产精品高潮久久久久无| 在线播放/欧美激情| 成人亚洲一区二区一| 亚洲成av人片在线观看| 久久久久久黄色| 日本大香伊一区二区三区| 奇米精品一区二区三区在线观看一 | 国产精一品亚洲二区在线视频| 亚洲视频网在线直播| 日韩欧美国产一区在线观看| 不卡一二三区首页| 日韩精品一级中文字幕精品视频免费观看 | 亚洲欧美电影院| 日韩欧美色电影| 91女人视频在线观看| 日本视频在线一区| 亚洲日本丝袜连裤袜办公室| 日韩午夜激情电影| 成av人片一区二区| 蜜桃传媒麻豆第一区在线观看| 国产精品国产三级国产三级人妇| 欧美一级午夜免费电影| 99久久99精品久久久久久| 另类小说综合欧美亚洲| 亚洲自拍都市欧美小说| 久久久精品黄色| 日韩欧美一级二级| 欧美三级在线播放| 91麻豆swag| 成人黄色小视频| 韩国女主播一区二区三区|