コード例 #1
0
/*! \brief Initializes attrubutes using t0_n, rot0_n, L0m_n,  order_default_n, move_n and tStep inputs.
*
* Inputs are checked.
*
* #tdelay method is used to set #DelayStore attribute
*
* #position method is used to set #SCposStore attribute
*
* Attributes are set :

*
* \arg	#arot =\f$ \frac{2 \cdot \pi}{3} \f$
* \arg	#rot :\f$ rot[i] = i \cdot arot \cdot rot0  \textrm{ for i=1,2,3 } \f$
* \arg	#crot : \f$ crot[i] = cos(rot_i)  \textrm{ for i=1,2,3 } \f$
* \arg	#srot : \f$ srot[i=0,1,2] = sin(rot_i) \textrm{ for i=1,2,3 } \f$
* \arg	#SCposStore :\f$ SCposStore[i] = position(i,0) \textrm{ for i=1,2,3,4 }  \f$
* \arg	#DelayStore :
* \f$  \textrm{ for i=1,2,3,4 }  
* \left\{  \begin{array}{l} 
	* DelayStore[i-1] = tdelay(i,i,mod((i+1),3)+1,2,0) \\ 
	* DelayStore[i+2] = tdelay(i,i,mod(i,3)+1,2,0)
	* \end{array} \right. \f$
	* \arg	#tRangeStorePos = #tRangeStorePos_default
	* \arg	#tRangeStoreDelay = \f$ min(tStep,tRangeStoreDelay\_default) \f$
	*/
void GeometryMLDC::init(double t0_n, double rot0_n, double L0m_n, int order_default_n, int move_n, double tStep)
{
	//cout << "Create orbits : MLDC ..." << endl;
	
	initGlobal(t0_n, rot0_n, L0m_n, order_default_n, move_n, tStep);
	Approx = move_n;
			
	arot=2./3.*M_PI;
	rot.resize(3);
	crot.resize(3);
	srot.resize(3);
	for(int nb=1; nb<=3; nb++){
		rot[nb-1]=(nb-1)*arot+rot0;
		crot[nb-1]=cos(rot[nb-1]);
		srot[nb-1]=sin(rot[nb-1]);
	}
	
	e_mldc = 0.00964838;
	
	L0s = L0m/c_SI;
	
	sqrt_3 = sqrt(3.0);
	i32 = 1.0/32.0;
	r1532 = 15.0/32.0;
	pi3o2 = 3.0*M_PI/2.0;
	pi2o3 = 2.0*M_PI/3.0;
	pi4o3 = 4.0*M_PI/3.0;
	
	
	
	for(int i=1; i<4; i++){
		SCposStore[i-1] = position(i,0.0);
	}
	
	for(int i=1; i<4; i++){
		DelayStore[i-1] = tdelay(i,(i+1)%3+1,2,0.0);
		//cout << " L" << i << (i+1)%3+1<< endl;
		DelayStore[i+2] = tdelay(i,i%3+1,2,0.0);
		//cout << " L" << i << i%3+1 << endl;
	}
	
	//cout << " --> OK" << endl;
}
コード例 #2
0
int main( int argc, char **argv )
{
    PomdpToolsProgOptions tool_options;
    PomdpSolveParams solve_params;

    tool_options = POMDP_TOOLS_OPTS_create( argc, argv );

    gStdErrFile = stderr;

    solve_params = newPomdpSolveParams();

    /* Manually set these. */
    gNumStates = tool_options->states;
    gNumObservations = tool_options->obs;

    /*
      CF_printf( POMDP_TOOLS_OPTS_toConfigFile( tool_options ) );
    */

    switch( tool_options->tool )
    {
    case POMDP_TOOLS_OPTS_Tool_compare_alphas:
        if (( tool_options->states < 1 )
                || ( strcmp( tool_options->alpha1, "" ) == 0 )
                || ( strcmp( tool_options->alpha2, "" ) == 0 )
                || ( strcmp( tool_options->result_filename, "" ) == 0 ))
        {
            fprintf( stderr, "Missing required arguments(s) for '%s'\n",
                     POMDP_TOOLS_OPTS_Tool_Str[tool_options->tool] );
            fprintf( stderr, "Need: %s, %s, %s and %s.\n",
                     POMDP_TOOLS_OPTS_ARG_ALPHA1_STR,
                     POMDP_TOOLS_OPTS_ARG_ALPHA2_STR,
                     POMDP_TOOLS_OPTS_ARG_O_STR,
                     POMDP_TOOLS_OPTS_ARG_STATES_STR );
            POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );
            exit( -1 );
        }


        UTIL_compareAlphaFiles( tool_options->alpha1,
                                tool_options->alpha2,
                                tool_options->epsilon,
                                tool_options->result_filename );
        break;

    case POMDP_TOOLS_OPTS_Tool_belief_alpha_compare:
        if (( tool_options->states < 1 )
                || ( strcmp( tool_options->alpha1, "" ) == 0 )
                || ( strcmp( tool_options->alpha2, "" ) == 0 )
                || ( strcmp( tool_options->belief, "" ) == 0 )
                || ( strcmp( tool_options->result_filename, "" ) == 0 ))
        {
            fprintf( stderr, "Missing required arguments(s) for '%s'\n",
                     POMDP_TOOLS_OPTS_Tool_Str[tool_options->tool] );
            fprintf( stderr, "Need: %s, %s, %s, %s and %s.\n",
                     POMDP_TOOLS_OPTS_ARG_ALPHA1_STR,
                     POMDP_TOOLS_OPTS_ARG_ALPHA2_STR,
                     POMDP_TOOLS_OPTS_ARG_BELIEF_STR,
                     POMDP_TOOLS_OPTS_ARG_O_STR,
                     POMDP_TOOLS_OPTS_ARG_STATES_STR );
            POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );
            exit( -1 );
        }


        UTIL_compareAlphaFilesUsingBeliefs( tool_options->alpha1,
                                            tool_options->alpha2,
                                            tool_options->belief,
                                            tool_options->epsilon,
                                            tool_options->result_filename );
        break;

    case POMDP_TOOLS_OPTS_Tool_pg_eval:
        if (( strcmp( tool_options->pomdp, "" ) == 0 )
                || ( strcmp( tool_options->pg1, "" ) == 0 ))
        {
            fprintf( stderr, "Missing required arguments(s) for '%s'\n",
                     POMDP_TOOLS_OPTS_Tool_Str[tool_options->tool] );
            fprintf( stderr, "Need: %s and %s.\n",
                     POMDP_TOOLS_OPTS_ARG_PG1_STR,
                     POMDP_TOOLS_OPTS_ARG_POMDP_STR );
            POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );
            exit( -1 );
        }

        /* See the pg-search-source/pg-eval-main.c file */

        initializePomdp( tool_options->pomdp,
                         1e-5 );

        PGE_main( tool_options->pg1 );

        cleanUpPomdp();

        break;

    case POMDP_TOOLS_OPTS_Tool_pg_relink:
        if (( strcmp( tool_options->pomdp, "" ) == 0 )
                || ( strcmp( tool_options->alpha1, "" ) == 0 )
                || ( strcmp( tool_options->alpha2, "" ) == 0 )
                || ( strcmp( tool_options->pg1, "" ) == 0 )
                || ( strcmp( tool_options->result_filename, "" ) == 0 ))
        {
            fprintf( stderr, "Missing required arguments(s) for '%s'\n",
                     POMDP_TOOLS_OPTS_Tool_Str[tool_options->tool] );
            fprintf( stderr, "Need: %s, %s, %s, %s and %s..\n",
                     POMDP_TOOLS_OPTS_ARG_ALPHA1_STR,
                     POMDP_TOOLS_OPTS_ARG_ALPHA2_STR,
                     POMDP_TOOLS_OPTS_ARG_POMDP_STR,
                     POMDP_TOOLS_OPTS_ARG_O_STR,
                     POMDP_TOOLS_OPTS_ARG_PG1_STR  );
            POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );
            exit( -1 );
        }

        initializePomdp( tool_options->pomdp,
                         1e-5 );

        UTIL_relinkPolicyGraph( tool_options->alpha1,
                                tool_options->pg1,
                                tool_options->alpha2,
                                tool_options->result_filename );

        cleanUpPomdp();

        break;

    case POMDP_TOOLS_OPTS_Tool_map_beliefs:
        if ( (tool_options->states < 1 )
                || ( strcmp( tool_options->belief, "" ) == 0 )
                || ( strcmp( tool_options->alpha1, "" ) == 0 )
                || ( strcmp( tool_options->result_filename, "" ) == 0 ))
        {
            fprintf( stderr, "Missing required arguments(s) for '%s'\n",
                     POMDP_TOOLS_OPTS_Tool_Str[tool_options->tool] );
            fprintf( stderr, "Need: %s, %s, %s and %s.\n",
                     POMDP_TOOLS_OPTS_ARG_BELIEF_STR,
                     POMDP_TOOLS_OPTS_ARG_ALPHA1_STR,
                     POMDP_TOOLS_OPTS_ARG_O_STR,
                     POMDP_TOOLS_OPTS_ARG_STATES_STR );
            POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );
            exit( -1 );
        }

        UTIL_mapBeliefList( tool_options->belief,
                            tool_options->alpha1,
                            tool_options->epsilon,
                            tool_options->result_filename );
        break;

    case POMDP_TOOLS_OPTS_Tool_pg_isomorphism:
        if ( (tool_options->obs < 1 )
                || ( strcmp( tool_options->pg1, "" ) == 0 )
                || ( strcmp( tool_options->pg2, "" ) == 0 ))
        {
            fprintf( stderr, "Missing required arguments(s) for '%s'\n",
                     POMDP_TOOLS_OPTS_Tool_Str[tool_options->tool] );
            fprintf( stderr, "Need: %s, %s and %s.\n",
                     POMDP_TOOLS_OPTS_ARG_PG1_STR,
                     POMDP_TOOLS_OPTS_ARG_PG2_STR,
                     POMDP_TOOLS_OPTS_ARG_OBS_STR );
            POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );
            exit( -1 );
        }

        fprintf( stderr, "This feature not yet implemented\n" );
        exit( -1 );
        break;

    case POMDP_TOOLS_OPTS_Tool_purge_alphas:
        if ( (tool_options->states < 1 )
                || ( strcmp( tool_options->alpha1, "" ) == 0 )
                || ( strcmp( tool_options->result_filename, "" ) == 0 ))
        {
            fprintf( stderr, "Missing required arguments(s) for '%s'\n",
                     POMDP_TOOLS_OPTS_Tool_Str[tool_options->tool] );
            fprintf( stderr, "Need: %s, %s and %s.\n",
                     POMDP_TOOLS_OPTS_ARG_ALPHA1_STR,
                     POMDP_TOOLS_OPTS_ARG_O_STR,
                     POMDP_TOOLS_OPTS_ARG_STATES_STR );
            POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );
            exit( -1 );
        }

        initCommon();
        initGlobal();
        initLpInterface( solve_params );

        UTIL_purgeAlphaFile( tool_options->alpha1,
                             tool_options->result_filename,
                             solve_params );
        break;

    case POMDP_TOOLS_OPTS_Tool_sort_alphas:
        if ( (tool_options->states < 1 )
                || ( strcmp( tool_options->alpha1, "" ) == 0 )
                || ( strcmp( tool_options->result_filename, "" ) == 0 ))
        {
            fprintf( stderr, "Missing required arguments(s) for '%s'\n",
                     POMDP_TOOLS_OPTS_Tool_Str[tool_options->tool] );
            fprintf( stderr, "Need: %s, %s and %s.\n",
                     POMDP_TOOLS_OPTS_ARG_ALPHA1_STR,
                     POMDP_TOOLS_OPTS_ARG_O_STR,
                     POMDP_TOOLS_OPTS_ARG_STATES_STR );
            POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );
            exit( -1 );
        }

        UTIL_sortAlphaFile( tool_options->alpha1,
                            tool_options->result_filename );

        break;

    case POMDP_TOOLS_OPTS_Tool_update_beliefs:
        if ( strcmp( tool_options->pomdp, "" ) == 0 )
        {
            fprintf( stderr, "Missing required arguments(s) for '%s'\n",
                     POMDP_TOOLS_OPTS_Tool_Str[tool_options->tool] );
            fprintf( stderr, "Need: %s.\n",
                     POMDP_TOOLS_OPTS_ARG_POMDP_STR );
            POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );
            exit( -1 );
        }

        initializePomdp( tool_options->pomdp,
                         1e-5 );

        UTIL_doBeliefUpdates();

        if ( gInitialBelief == NULL )
        {
            fprintf( stderr,
                     "POMDP file '%s' must specify a starting belief state\n",
                     tool_options->pomdp );
            fprintf( stderr, "Aborted.\n" );
            exit( -1 );
        }

        cleanUpPomdp();
        break;

    default:
        fprintf( stderr, "Unreckognized tool option\n" );
        POMDP_TOOLS_OPTS_showUsageBrief( stderr, argv[0] );

        exit( -1 );

    } /* switch param->tool */

    /* This will also take care of deallocating the 'opts' structure. */
    destroyPomdpSolveParams( solve_params );

    return 0;
} /* main */
コード例 #3
0
ファイル: main.c プロジェクト: fmccabe/l-and-o
/*
 * Go evaluator main program
 */
int main(int argc, char **argv) {
  int narg;

#ifdef HAVE_LOCALECONV
  setlocale(LC_ALL,"");		/* set up locale */
#endif

#ifdef LOCALEDIR
  bindtextdomain(PACKAGE,LOCALEDIR);
  textdomain(PACKAGE);
#endif

  initLogfile((char *) "-");
  initFileIo();        /* Set up special file handling */

  strMsg(entryPoint, NumberOf(entryPoint), "lo.boot@__boot"); /* standard entry point */

  if ((narg = getOptions(argc, argv)) < 0) {
    outMsg(logFile, _("usage: %s [-v] [-L log] [-g host:port] [-V] [-b boot:ver] [-m entry] [-r repo] [-d wd]"
                        " [-h sizeK] [-s sizeK] [-d rootdir] args ...\n"), argv[0]);
    exit(1);
  }

  // Set up repository directory
  if (uniIsLit(repoDir, "")) { // overridden?
    char *dir = getenv("LO_DIR"); /* pick up the installation directory */
    if (dir == NULL)
      dir = LODIR;                  /* Default installation path */
    uniCpy(repoDir, NumberOf(repoDir), dir);
  }

  // set up working directory
  if (uniIsLit(loCWD, "")) {
    char cbuff[MAXPATHLEN];
    char *cwd = getcwd(cbuff, NumberOf(cbuff)); /* compute current starting directory */
    if (cwd == NULL)
      syserr("cant determine current directory");
    else
      strMsg(loCWD, NumberOf(loCWD), "%s/", cwd);
  }

  if (loadManifest(repoDir) != Ok) {
    outMsg(logFile, "error in loading repository from %s", repoDir);
    exit(99);
  }

  /* IMPORTANT -- Keep the order of these set up calls */
  initGlobal(initHeapSize);    /* start up the global space */
  initClass();        /* Initialize the class handlers */
  initPrograms();      /* Initialize program handling */
  initDict();        /* Start up the dictionaries */
  install_escapes();      /* Initialize the escape table */
  initFiles();        /* initialize file tables */
  init_args(argv, argc, narg);    /* Initialize the argument list */
  init_time();        /* Initialize time stuff */

  setupSignals();

#ifdef EXECTRACE
  if (traceCount)
    atexit(dumpInsCount);
#endif

  bootstrap(entryPoint, bootPkg, bootVer);

  return EXIT_SUCCEED;          /* exit the lo system cleanly */
}