Example #1
0
int main()
{
	int i, j;
	char c;
	char temp[20];
	scanf("%d%d\n", &cols, &rows);
	for(i = 0; i < rows; i++) 
	{
		gets(temp);
		for(j = 0; j < cols; j++)
		{
			c = temp[j];
			if(c == '.') map[i][j] = 0;
			else 
			{
				map[i][j] = c-'@';
				if (c!='X')
				{
					c -= 'A';
					site[c].x = i; 
					site[c].y = j;
				}
			}
		}
	}
	memset(factor, 0, sizeof(factor));
	char c1, c2;
	double load;
	while (1)
	{
		scanf("%c%c%lf\n", &c1, &c2, &load);
		if(c1 == 'X' && c2 == 'X') break;
		memset(steps, 255, sizeof(steps));
		memset(times, 0, sizeof(times));
		c1 -= 'A';
		c2 -= 'A';
		int dx = site[c2].x;
		int dy = site[c2].y;
		map[dx][dy] = 0;
		
		bfs_path(c1, dx, dy);
		bfs_times();

		map[dx][dy] = (++c2);
		load /= times[dx][dy];
		loadFactors(dx, dy, load);
	}
	for(i = 0; i < rows; i++) 
	{
		for(j = 0; j < cols; j++)
		{
			if (map[i][j]) factor[i][j] = 0;
			if (j) printf(" ");
			printf("%6.2lf", factor[i][j]);
		}
		printf("\n");
	}
	return(0);
}
Example #2
0
void loadFactors(int x, int y, double load)
{
	factor[x][y] += load * times[x][y];
	int point = steps[x][y];	
	if((point) <= 1) return;
	point--;
	int i;
	for(i = 0; i < 4; i++)
		if(siteValid(x + xOffset[i], y + yOffset[i]) == point)
			loadFactors(x + xOffset[i], y + yOffset[i], load);
}
Example #3
0
void 
FireLoadPattern::applyLoad(double time)
{
  // first determine the load factor
  if (theSeries1 != 0 && isConstant != 0) {
    loadFactors(0) = theSeries1->getFactor(time);
    loadFactors(1) = theSeries2->getFactor(time);
    loadFactors(2) = theSeries3->getFactor(time);
    loadFactors(3) = theSeries4->getFactor(time);
    loadFactors(4) = theSeries5->getFactor(time);
    loadFactors(5) = theSeries6->getFactor(time);
    loadFactors(6) = theSeries7->getFactor(time);
    loadFactors(7) = theSeries8->getFactor(time);
    loadFactors(8) = theSeries9->getFactor(time);
  }
  //this is a fire load pattern so we always need multiple timeseries
  ElementalLoad *eleLoad;
  ElementalLoadIter &theElementalIter = this->getElementalLoads();
  while ((eleLoad = theElementalIter()) != 0)
    eleLoad->applyLoad(loadFactors);
}