Beispiel #1
0
int main()
{
    config_parse_remote_servers("servers.txt");

    trainingdata_t* data = trainingdata_new();

    int t;
    for(t=0;t<256;t++) {
        example_t*e = example_new(16);
        int s;
        for(s=0;s<16;s++) {
            e->inputs[s] = variable_new_continuous((lrand48()%256)/256.0);
        }
        e->desired_response = variable_new_categorical(t%2);
        trainingdata_add_example(data, e);
    }

    trainingdata_save(data, "/tmp/data.data");
    trainingdata_destroy(data);

    data = trainingdata_load("/tmp/data.data");

    model_t*m = model_select(data);

    char*code = model_generate_code(m, "python");
    printf("%s\n", code);
    free(code);

    model_destroy(m);

    trainingdata_destroy(data);
}
Beispiel #2
0
static void clear_level(void)
{
	DEBUG(2, "game: clear_level()\n");
	if (level)
	{
		DEBUG(1, "Unloading level\n");
		model_destroy(level);
		lua_pushnil(L1);
		lua_setglobal(L1, "level");
		lua_gc(L1, LUA_GCCOLLECT, 0);
		level = NULL;
	}
}
Beispiel #3
0
void fit_destroy(fitinfo *fit)
{
  pars_destroy(&fit->pars);
  profile_destroy(&fit->p);
  model_destroy(&fit->m);
  data_destroy(&fit->dataA);
  data_destroy(&fit->dataB);
  data_destroy(&fit->dataC);
  data_destroy(&fit->dataD);
  interface_destroy(&fit->rm);
  if (fit->worksize>0) free(fit->work);
  if (fit->capacity>0) free(fit->fitQ);
  fit->capacity = -1;
  fit->nQ = 0;
  fit->worksize = 0;
}
Beispiel #4
0
int model_extend(model *m, int n)
{
  int i;

  if (m->capacity < 0) return 0;
  if (m->n+n > m->capacity) {
    int old_size = m->capacity;
    int new_size = m->capacity + n;
    new_size += new_size/10 + 20; /* 10% spare */
    if (new_size < MODEL_LENGTH_DEFAULT) new_size = MODEL_LENGTH_DEFAULT;
    if (m->capacity <= 0) {
      m->mu = malloc(MODEL_FIELDS*sizeof(Real)*new_size);
    } else {
      m->mu = realloc(m->mu,MODEL_FIELDS*sizeof(Real)*new_size);
      if (m->mu != NULL) {
	for (i=MODEL_FIELDS-1; i>0; i--) {
	  memmove(m->mu+i*new_size,m->mu+i*old_size,old_size*sizeof(Real));
	}
      }
    }
    m->rho = m->mu + new_size;
    m->d = m->mu + 2*new_size;
    m->rough = m->mu + 3*new_size;
#ifdef HAVE_MAGNETIC
    m->P = m->mu + 4*new_size;
    m->Prough = m->mu + 5*new_size;
    m->theta = m->mu + 6*new_size;
    m->thetarough = m->mu + 7*new_size;
#endif
    m->capacity = new_size;
    if (m->mu==NULL) {
      model_destroy(m);
      m->capacity = -1; /* remember that we destroyed the profile */
      return 0;
    }
  }
  return 1;
}