Ejemplo n.º 1
0
/*-----------------------------------------------------------------------------*/
int main (int argc, char* argv[]) {

    int    I 	= argdf ('I',argc,argv,0);
    int    n 	= arg   ('n',argc,argv);
    int    N 	= arg   ('N',argc,argv);
    double m 	= farg  ('m',argc,argv);
    double ke 	= farg  ('k',argc,argv);
    int    Wmax = arg   ('W',argc,argv);
    int    Cmax = arg   ('C',argc,argv);
    int    d    = targ  ('d',argc,argv);

    long ttw, tw; int i,j; int M;
    int* weights = (int*)malloc(n*sizeof(int));
    int* costs   = (int*)malloc(n*sizeof(int));

    srandom(time(NULL));
    ttw=0;
    for (j=0; j<N; j++) {
        tw=knapcore (weights, costs, n, Wmax, Cmax, ke, d); ttw+=tw; M=m*tw;
	printf ("%d %d %d",I+j, n, M);
	for (i=0; i<n; i++) printf (" %d %d", weights[i], costs[i]);
	printf ("\n");
        fprintf (stderr, "total weight %ld\n", tw);
    }
    fprintf (stderr, "average total weight %.2f; first unused instance id %d\n",
	(double) ttw / (double) N, I+N);
    return 0;
}
Ejemplo n.º 2
0
bool TestCmdlineParser::TestParams::interpreteParameters ()
{
    bool toR = Process_params::interpreteParameters ();
    if (toR)
    {
        kstr  (parameters_->getParameter ("TESTSECT", "KSTR"));
        kbool (parameters_->getBoolean ("TESTSECT", "KBOOL"));
        kint  (parameters_->getInteger ("TESTSECT", "KINT"));

        farg  (parameters_->getParameter (volatile_section_name, "farg"));
        oarg  (parameters_->getParameter (volatile_section_name, "oarg"));
        rargs (parameters_->getParameter (volatile_section_name, "rarg"));
        larg  (parameters_->getParameter (volatile_section_name, "larg"));
    }
    return toR;
}
Ejemplo n.º 3
0
void setArgs( struct args& a, int argc, char *argv[])
{
	for( int ac = 0; ac < argc; ac++)
	{
		std::cout << "Checking " << argv[ac] << "\n";
		if( ac == 0)
			continue;
		std::string arg(argv[ac]);
		if( arg == "-v" )
		{
			a.v = true;
			a.vp = ac;
		}
		if( arg == "-b" )
		{
			a.b = true;
			a.bp = ac;
		}
		if( arg == "-bbox" )
		{
			a.bbox = true;
			a.bboxp = ac;
		}
		if( arg == "-c" )
		{
			a.c = true;
			a.cp = ac;
		}
		if( arg == "-cd" )
		{
			a.cd = true;
			a.cdp = ac;
		}
		if( arg == "-ptc" )
		{
			a.ptc = true;
			a.ptcp = ac;
		}
		if( arg == "-ptcd" )
		{
			a.ptcd = true;
			a.ptcdp = ac;
		}
		if( a.v )
		{
			if( ac == (a.vp + 1))
			{
				UT_String intarg(argv[ac]);
				std::cout << "Verbosity argument: " << intarg.toInt() << "\n";
				logger.setLogLevel((Logging::LogLevel)intarg.toInt());
			}
		}
		if( a.bbox )
		{
			if( ac == (a.bboxp + 1))
			{
				a.bboxfile = std::string(argv[ac]);
				std::cout << "bbox file " << a.bboxfile << "\n";
			}
		}	
		if( a.ptc )
		{
			if( ac == (a.ptcp + 1))
			{
				a.ptcfile = std::string(argv[ac]);
				std::cout << "pointcloud file " << a.ptcfile << "\n";
			}
		}	
		if( a.ptcd )
		{
			if( ac == (a.ptcdp + 1))
			{
				UT_String farg(argv[ac]);
				a.ptcdv = farg.toFloat();
				std::cout << "pointcloud file density " << a.ptcdv << "\n";
			}
		}	
		if( a.c )
		{
			if( ac == (a.cp + 1))
			{
				a.cFile = std::string(argv[ac]);
				std::cout << "convert file " << a.cFile << "\n";
			}
		}	
		if( a.cd )
		{
			if( ac == (a.cdp + 1))
			{
				a.cdDir = std::string(argv[ac]);
				std::cout << "convert dir " << a.cdDir << "\n";
			}
		}	
	}
}