示例#1
0
int main( )
{
	struct airport a ;
	int i, pri, curtime, endtime ;
	double expectarrive, expectdepart ;
	struct plane temp ;

  system ( "cls" ) ;

    initairport ( &a );

	start ( &endtime, &expectarrive, &expectdepart ) ;

	for ( curtime = 1 ; curtime <= endtime ; curtime++ )
	{
		pri = randomnumber ( expectarrive ) ;

		for ( i = 1 ; i <= pri ; i++ )
		{
			newplane ( &a, curtime, ARRIVE ) ;
			if ( apfull ( a, 'l' ) )
				 refuse ( &a, ARRIVE ) ;
			else
				apaddqueue( &a, 'l' ) ;
		}

		pri = randomnumber ( expectdepart ) ;
		for ( i = 1 ; i <= pri ; i++ )
		{
			newplane ( &a, curtime, DEPART ) ;
			if ( apfull ( a, 't' ) )
			   refuse ( &a, DEPART ) ;
			else
			   apaddqueue ( &a, 't' ) ;
		}

		if (  ! ( apempty ( a, 'l' ) ) )
		{
			temp = apdelqueue ( &a, 'l' ) ;
			land ( &a, temp, curtime ) ;
		}
		else
		{
			if ( ! ( apempty ( a, 't' ) ) )
			{
				temp = apdelqueue ( &a, 't' ) ;
				fly ( &a, temp, curtime ) ;
			}
			else
				idle ( &a, curtime ) ;
		}
	}

	conclude ( &a, endtime ) ;

    return 0 ;
}
示例#2
0
文件: api.c 项目: taohonker/Ovito
void rt_plane3fv(SceneHandle scene, void * tex,
                 const float *ctr, const float *norm) {
  vector vctr, vnorm;
  vctr.x = ctr[0];   vctr.y = ctr[1];   vctr.z = ctr[2];
  vnorm.x = norm[0]; vnorm.y = norm[1]; vnorm.z = norm[2];
  add_unbounded_object((scenedef *) scene, newplane(tex, vctr, vnorm));
} 
    bool fme_is_feasible(const Conjunction &space) 
    {
        int n = space.size();   // number of inequalities

        std::vector<Plane> planes = get_normalized_planes(space);
        assert(planes.size() == n);
        int m = planes[0].size();

        //std::cout << "Size is " << n << " x " << m << std::endl;

        for (unsigned k=0; k<m; ++k) {
            // eliminate the k-th variable;
            std::vector<Plane> neg, pos, nix;
            split_planes(planes, k, neg, pos, nix);

            planes.clear();
            for (auto &x : nix) 
                planes.push_back(x);
            
            for (auto &x : neg) {
                for (auto &y : pos) {
                    double xc = x.a[k];
                    double yc = y.a[k];
                    coeff_row_t newrow(m);
                    for (unsigned h=0; h<m; ++h) 
                        newrow[h] = x.a[h] - y.a[h] * xc/yc;
                    int s = Plane::lt; 
                    if (x.sign == Plane::lte && y.sign == Plane::lte) 
                        s = Plane::lte;
                    double b = x.b - y.b *xc/yc;
                    Plane newplane(newrow, s, b);
                    planes.push_back(newplane);
                }
            }
        }
        // all variables have been eliminated, now there remain only
        // tautologies (0 <= b) or contradictions
 
        // look for contradictions
        for (auto &x : planes) {
            if (x.sign == Plane::lte && x.b < 0) return false;
            else if (x.sign == Plane::lt && x.b <=0) return false;
        }
        return true;
    }
示例#4
0
void rt_plane(void * tex, vector ctr, vector norm) {
  add_object(newplane(tex, (vector)ctr, (vector)norm));
} 
示例#5
0
文件: api.c 项目: taohonker/Ovito
void rt_plane(SceneHandle scene, void * tex, apivector ctr, apivector norm) {
  add_unbounded_object((scenedef *) scene, newplane(tex, ctr, norm));
} 
示例#6
0
int
addplane(void)
{
	PLANE	p, *pp, *p1;
	int	i, num_starts, close, rnd, rnd2, pnum;

	memset(&p, 0, sizeof (p));

	p.status = S_MARKED;
	p.plane_type = atcrandom() % 2;

	num_starts = sp->num_exits + sp->num_airports;
	rnd = atcrandom() % num_starts;

	if (rnd < sp->num_exits) {
		p.dest_type = T_EXIT;
		p.dest_no = rnd;
	} else {
		p.dest_type = T_AIRPORT;
		p.dest_no = rnd - sp->num_exits;
	}

	/* loop until we get a plane not near another */
	for (i = 0; i < num_starts; i++) {
		/* loop till we get a different start point */
		while ((rnd2 = atcrandom() % num_starts) == rnd)
			;
		if (rnd2 < sp->num_exits) {
			p.orig_type = T_EXIT;
			p.orig_no = rnd2;
			p.xpos = sp->exit[rnd2].x;
			p.ypos = sp->exit[rnd2].y;
			p.new_dir = p.dir = sp->exit[rnd2].dir;
			p.altitude = p.new_altitude = 7;
			close = 0;
			for (p1 = air.head; p1 != NULL; p1 = p1->next)
				if (too_close(p1, &p, 4)) {
					close++;
					break;
				}
			if (close)
				continue;
		} else {
			p.orig_type = T_AIRPORT;
			p.orig_no = rnd2 - sp->num_exits;
			p.xpos = sp->airport[p.orig_no].x;
			p.ypos = sp->airport[p.orig_no].y;
			p.new_dir = p.dir = sp->airport[p.orig_no].dir;
			p.altitude = p.new_altitude = 0;
		}
		p.fuel = sp->width + sp->height;
		break;
	}
	if (i >= num_starts)
		return (-1);
	pnum = next_plane();
	if (pnum < 0)
		return (-1);
	p.plane_no = pnum;

	pp = newplane();
	memcpy(pp, &p, sizeof (p));

	if (pp->orig_type == T_AIRPORT)
		append(&ground, pp);
	else
		append(&air, pp);

	return (pp->dest_type);
}