예제 #1
0
void City::add_staging_area(Location loc, int* inventories, int capacity)
{
	clear_intermediates();

	DumpsterSize sizes[] = {smallest, small, big, biggest};
	location l = add_location(loc);
	for (int j = 0; j < 4; j++)
	{
		add_stop(new Action
		{
			Store,
			sizes[j],
			none,
			0,
			sh_time_look_ahead,
			STAGE_TIME,
			l
		});
		add_stop(new Action
		{
			UnStore,
			none,
			sizes[j],
			0,
			sh_time_look_ahead,
			STAGE_TIME,
			l
		});
	}

	staging_areas.insert(std::pair<int, StagingArea>{l, StagingArea{l, capacity, inventories}});
}
예제 #2
0
void TLens::add_stop(double radius, double thickness)
{
    TDisk* disk = new TDisk(radius);
    QSharedPointer<TDisk> pDisk(disk);

    return add_stop(pDisk, thickness);
}
예제 #3
0
파일: short.c 프로젝트: mhspradlin/c
struct path *find_shortest_ (int **weights, struct path **cache, struct node **graph, int id1, int id2) {
    printf ("id1: %d, id2: %d\n", id1, id2);
    if (id1 == id2) {
        struct path *stub = new_path (id1);
        cache[id1] = stub;
        return stub;
    }

    // If the path passed to us is a cycl
    
    //struct node *start = get_node (graph, id1);
    struct node *end = get_node (graph, id2);

    // Get all of the shortest paths for the predecessors
    // Also, the shortest path to us is us plus the shortest of the paths to our
    // predecessors
    int i;
    int min = 65535;
    int minpath = 0;
    for (i = 0; i < end->num_back; i++) {
        struct path *cur = cache[end->back[i]];
        // Only do work if we have to
        if (cur == NULL) {
            cur = find_shortest_ (weights, cache, graph, id1, end->back[i]);
        }
	    // Now we definitely have a value
        if (cur->numelems > 0 && cur->length + weights[end->back[i]][id2] < min) {
            min = cur->length + weights[end->back[i]][id2];
            minpath = end->back[i];
        }
    }

    // If there's no path, return that
    // We also get here if there's nobody behind us
    if (min == 65535)
        return no_path ();


    // Add us to the cache and return
    struct path *our_shortest = add_stop (weights, cache[minpath], minpath, id2);

    // If we've cycled (only happens if there's a negative cycle) then print out
    // that we have a negative cycle and the path that has it
    // Might not terminate if we do... Hmm...
    if (has_cycle (our_shortest)) {
        printf ("======== We have a cycle =======\n");
        print_path (our_shortest);
        printf("================\n");
    }

    // Add us to the cache
    cache[id2] = our_shortest;
    return our_shortest;
}
예제 #4
0
void step( int p)//how_far[p] displays how far has the man number p gone in his path
{
if ( (hm[p]->gone!=1) && ( co[ px [how_far[p]+1] [p] ] [py [how_far[p]+1] [p] ] ==1 ) )
	add_stop (p);

if ( (hm[p]->gone!=1) && ( co[ px [how_far[p]+1] [p] ] [py [how_far[p]+1] [p] ] !=1 ) )
	if  (co[ px [how_far[p]+1] [p] ] [ py [how_far[p]+1] [p] ]!=2)  
	{
	co[ px [how_far[p]+1] [p] ] [ py [how_far[p]+1] [p] ] = 1;
	co [ px [how_far[p]] [p] ]  [ py [how_far[p]] [p] ] = 0;   
	how_far[p]++;	
	}
else 
	{
	co [ px [how_far[p]] [p] ]   [ py [how_far[p]] [p] ]=0;
	how_far[p]++;
	}
if (how_far[p]>=length[p])  hm[p]->gone=1;
}
예제 #5
0
void City::add_land_fill(Location loc)
{
	clear_intermediates();

	DumpsterSize sizes[] = {smallest, small, big, biggest};
	location l = add_location(loc);
	for (int j = 0; j < 4; j++)
	{
		add_stop(new Action
		{
			Dump,
			sizes[j],
			sizes[j],
			0,
			sh_time_look_ahead,
			LANDFILL_TIME,
			l
		});
	}
}
예제 #6
0
// Returns a pointer to an array of vectors (one vector for each realline), not a pointer to a vector.
vector_t *TRS_get(const struct WBlocks *wblock, const struct WTracks *wtrack){
  int num_reallines = wblock->num_reallines;
  vector_t *trs = talloc(sizeof(vector_t) * num_reallines);

  struct Notes *note = wtrack->track->notes;
  while(note!=NULL){
    add_note(wblock, trs, note);
    note = NextNote(note);
  }

  struct Stops *stop = wtrack->track->stops;
  while(stop!=NULL){
    add_stop(wblock, trs, stop);
    stop = NextStop(stop);
  }

  spread_trackreallines(wblock, trs);
    
  //  if (wtrack->l.num==0)
  //   TRS_print(wblock,trs);
  
  return trs;
}
예제 #7
0
void City::add_request(Action* action)
{
	clear_intermediates();

	add_stop(action);
}