示例#1
0
文件: predk.c 项目: 1014511134/src
void predk_init(int nk          /* number of components */,
		int m1, int m2  /* data dimensions */, 
		float eps       /* regularization parameter */,
		int order       /* accuracy order */,
		float*** pk     /* slopes [nk][m1][m2] */)
/*< initialize >*/
{
    n=nk;
    p=pk;
    n12=m1*m2;

    predict_init(m1,m2,eps,order,1,false);
}
示例#2
0
void seislet_init(int n1      /* trace length */, 
		  int n2      /* number of traces */, 
		  bool inv1   /* inversion flag */, 
		  bool unit1  /* weighting flag */,
		  float eps   /* regularization parameter */,
		  char type   /* transform type */) 
/*< allocate space >*/
{
    int i,j;
    float wi;

    inv = inv1;
    unit = unit1;

    n = n1;
    for (nt=1; nt < n2; nt *= 2) ;
    t = sf_floatalloc2(n,nt);
    predict_init (n, nt, eps*eps, 1);

    t1 = sf_floatalloc(n);
    t2 = sf_floatalloc(n);

    switch(type) {
	case 'h': 
	    transform = haar;
	    break;
	case 'l':
	    transform = linear;
	    break;
	case 'b':
	    transform = biorthogonal;
	    break;
	default:
	    sf_error("Unknown wavelet type=%c",type);
	    break;
    }

    if (unit) {
	w = sf_floatalloc(nt);

	w[0] = sqrtf((float) nt);
	wi = 0.5;	
	for (j=1; j <= nt/2; j *= 2, wi *= 2) {
	    for (i=0; i < nt-j; i += 2*j) {
		w[i+j] = sqrtf(wi);
	    }
	}
    }
}
示例#3
0
void smoothpwd_init(int n1, int n2 /* data size */,
		    float eps      /* PWD regularization */,
		    int order      /* accuracy order */,
		    int rect1      /* vertical smoothing radius */, 
		    float **dip    /* dip field [n2][n1] */)
/*< initialize >*/
{
    n = n1*n2;

    sf_repeat_init(n1,n2,sf_causint_lop);
    predict_init (n1,n2,eps,order,1,false);
    predict_set(dip);
    sf_triangle2_init (rect1,1,n1,n2,1);

    w = sf_floatalloc(n);
    p = sf_floatalloc(n);
    t = sf_floatalloc(n);
}
示例#4
0
int main(void) {
    double dot1[2], dot2[2];
    static int n1=100, n2=100, rect=3, order=3; 
    int i1, i2;
    float **p;

    p = sf_floatalloc2(n1,n2);

    for (i2=0; i2 < n2; i2++) {
	for (i1=0; i1 < n1; i1++) {
	    p[i2][i1] = (i1-n1/2)*(i2-n2/2)/((n1-1.)*(n2-1.));
	}
    }

    predict_init(n1, n2, 0.01, order, rect,false);
    predict_set(p);
    sf_dot_test(predict_lop, n1*n2, n1*n2, dot1, dot2);

    printf ("%12.8f ? %12.8f\n",dot1[0],dot1[1]);
    printf ("%12.8f ? %12.8f\n",dot2[0],dot2[1]);

    sf_dot_test(subtract_lop, n1*n2, n1*n2, dot1, dot2);

    printf ("%12.8f ? %12.8f\n",dot1[0],dot1[1]);
    printf ("%12.8f ? %12.8f\n",dot2[0],dot2[1]);

    n2 += 2*rect;
    
    sf_dot_test(predicter_lop, n1*n2, n1*n2, dot1, dot2);

    printf ("%12.8f ? %12.8f\n",dot1[0],dot1[1]);
    printf ("%12.8f ? %12.8f\n",dot2[0],dot2[1]);

    sf_dot_test(subtracter_lop, n1*n2, n1*n2, dot1, dot2);

    printf ("%12.8f ? %12.8f\n",dot1[0],dot1[1]);
    printf ("%12.8f ? %12.8f\n",dot2[0],dot2[1]);

    predict_close();
    exit(0);
}
示例#5
0
int main (int argc, char *argv[])
{
    bool verb;
    int n1,n2,n3, n12, n23, ref2, ref3, i2,i3,i1, ud, lr, order;
    float eps, ***dat, ***p, ***q, **p2, **q2, *trace;
    sf_file dip, out, seed, cost;

    sf_init(argc,argv);
    dip = sf_input("in");
    out = sf_output("out");
    seed = sf_input("seed");
    cost = sf_input("cost");

    if (!sf_histint(dip,"n1",&n1)) sf_error("No n1= in input");
    if (!sf_histint(dip,"n2",&n2)) sf_error("No n2= in input");
    if (!sf_histint(dip,"n3",&n3)) sf_error("No n3= in input");
    n23 = n2*n3;
    n12 = n1*n23;

    if (!sf_getbool("verb",&verb)) verb=false;
    if (!sf_getfloat("eps",&eps)) eps=0.01;
    /* regularization */

    if (!sf_getint("ref2",&ref2)) ref2=0;
    if (!sf_getint("ref3",&ref3)) ref3=0;
    /* reference trace */

    sf_putint(out,"n4",1);

    p = sf_floatalloc3(n1,n2,n3);
    q = sf_floatalloc3(n1,n2,n3);
    dat = sf_floatalloc3(n1,n2,n3);

    sf_floatread(p[0][0],n12,dip);
    sf_floatread(q[0][0],n12,dip);

    p2 = sf_floatalloc2(n2,n3);
    q2 = sf_floatalloc2(n2,n3);

    sf_floatread(p2[0],n23,cost);
    sf_floatread(q2[0],n23,cost);

    dijkstra_init(n2,n3,p2,q2);
    dijkstra_source(ref2,ref3);
    sf_floatread(dat[ref3][ref2],n1,seed);
    if (verb) sf_warning("%d %d",ref2,ref3);

    if (!sf_getint("order",&order)) order=1;
    /* accuracy order */

    predict_init(n1,n2, eps*eps, order, 1, false);
    
    while (dijskstra_step(&i2,&i3,&ud,&lr)) {
	if (verb) sf_warning("%d %d",i2,i3);

	trace = dat[i3][i2];
	for (i1=0; i1 < n1; i1++) {
	    trace[i1] = dat[i3-lr][i2-ud][i1];
	} 
	if (ud > 0) {
	    predict_step(false,true,trace,p[i3][i2-ud]);
	} else if (ud < 0) {
	    predict_step(false,false,trace,p[i3][i2]);
	}

	if (lr > 0) {
	    predict_step(false,true,trace,q[i3-lr][i2]);
	} else if (lr < 0) {
	    predict_step(false,false,trace,q[i3][i2]);
	}
    }
	
    sf_floatwrite(dat[0][0],n12,out);

    exit (0);
}
示例#6
0
int main (int argc, char *argv[])
{
    bool verb, up2, up3;
    unsigned char update;
    int n1,n2,n3, i1,i2,i3, ns2, ns3, ip, np2, np3, n23;
    int order, np, i4, n4, k2, k3, j2, j3, i, jp, j;
    float eps, ***u, **p1, **p2, **cost, *trace, *q2=NULL, *q3=NULL;
    sf_file inp, out, dip;

    sf_init(argc,argv);
    inp = sf_input("in");
    dip = sf_input("dip");
    out = sf_output("out");

    if (!sf_histint(inp,"n1",&n1)) sf_error("No n1= in input");
    if (!sf_histint(inp,"n2",&n2)) sf_error("No n2= in input");
    if (!sf_histint(inp,"n3",&n3)) sf_error("No n3= in input");
    n23 = n2*n3;
    n4 = sf_leftsize(inp,3);

    if (!sf_getbool("verb",&verb)) verb=false;
    /* verbosity */
    if (!sf_getfloat("eps",&eps)) eps=0.01;
    /* regularization */
    
    if (!sf_getint("order",&order)) order=1;
    /* accuracy order */

    if (!sf_getint("ns2",&ns2)) sf_error("Need ns1=");
    if (!sf_getint("ns3",&ns3)) sf_error("Need ns2=");
    /* spray radius */
    np2 = 2*ns2+1;
    np3 = 2*ns3+1;
    np = np2*np3;

    sf_putint(out,"n2",np);
    sf_shiftdim(inp, out, 2);

    cost = sf_floatalloc2(np2,np3);
    for (i3=0; i3 < np3; i3++) {
	for (i2=0; i2 < np2; i2++) {
	    cost[i3][i2] = hypotf(i2-ns2,i3-ns3);
	}
    }

    predict_init (n1, n2, eps*eps, order, 1, true);
    update_init(np2,np3,*cost);

    u = sf_floatalloc3(n1,np,n23);
    for (i3=0; i3 < n23; i3++) {
	for (ip=0; ip < np; ip++) {
	    for (i1=0; i1 < n1; i1++) {
		u[i3][ip][i1] = 0.;
	    }
	}
    }

    p1 = sf_floatalloc2(n1,n23);
    p2 = sf_floatalloc2(n1,n23);

    for (i=0; i < n23; i++) { 
	sf_floatread(p1[i],n1,dip);
    }

    for (i=0; i < n23; i++) { 
	sf_floatread(p2[i],n1,dip);
    }

    for (i4=0; i4 < n4; i4++) {
	for (i=0; i < n23; i++) { 
	    sf_floatread(u[i][ns3*np2+ns2],n1,inp);
	    
	    i2 = i%n2;
	    i3 = i/n2;

	    for (ip=0; ip < np; ip++) {
		update = get_update(ip,&up2,&up3,&jp);
		
		/* from jp to j */
		k2 = jp%np2;
		k3 = jp/np2;
		
		j2 = i2+k2-ns2;
		j3 = i3+k3-ns3;

		if (j2 < 0 || j2 >= n2 || 
		    j3 < 0 || j3 >= n3) continue;

		j = j2+j3*n2;
		trace = u[j][jp];

		if (update & 1) {		
		    if (up2) {
			if (j2==0) continue;
			j2 = j-1;
			q2 = p1[j2];
			k2 = jp-1;
		    } else {
			if (j2==n2-1) continue;
			j2 = j+1;
			q2 = p1[j];
			k2 = jp+1;
		    }
		}
		if (update & 2) {
		    if (up3) {
			if (j3==0) continue;
			j3 = j-n2;
			q3 = p2[j3];
			k3 = jp-np2;
		    } else {
			if (j3==n3-1) continue;
			j3 = j+n2;
			q3 = p2[j];
			k3 = jp+np2;
		    }
		}

		switch(update) {
		    case 0:			
			break;
		    case 1:
			predict1_step(up2,u[j2][k2],q2,trace);
			break;
		    case 2:
			predict1_step(up3,u[j3][k3],q3,trace);
			break;
		    case 3:
			predict2_step(up2,up3,u[j2][k2],u[j3][k3],
				      q2,q3,trace);
			break;
		}
	    }
	}

	for (i=0; i < n23; i++) {
	    for (ip=0; ip < np; ip++) {
		sf_floatwrite(u[i][ip],n1,out);
	    }
	}
    }

    exit (0);
}
示例#7
0
int main (int argc, char *argv[])
{
    bool verb;
    int n1,n2,n3, i1,i2,i3, is, ns, ns2, ip, fold, niter, nit, order;
    float eps, perc, ***u, **p, *trace, **xk, **yk;
    sf_file inp, out, dip;
    char *type;

    sf_init(argc,argv);
    inp = sf_input("in");
    dip = sf_input("dip");
    out = sf_output("out");

    if (!sf_histint(dip,"n1",&n1)) sf_error("No n1= in input");
    if (!sf_histint(dip,"n2",&n2)) sf_error("No n2= in input");
    n3 = sf_leftsize(dip,2);

    if (!sf_getbool("verb",&verb)) verb=false;
    /* verbosity */
    if (!sf_getfloat("eps",&eps)) eps=0.01;
    /* regularization */
    
    if (!sf_getint("ns",&ns)) sf_error("Need ns=");
    /* spray radius */
    ns2 = 2*ns+1;

    if (NULL == (type=sf_getstring("type"))) type="difference";
    /* [difference,sharpen_similarity] calculation type, the default is difference  */


    switch (type[0]) {
	case 'd':
	    break;
	case 's':
	    if (!sf_getint("niter",&niter)) niter=20;
	    /* number of iterations */
	    
	    if (!sf_getfloat("perc",&perc)) perc=98.;
	    /* percentage for sharpen, default is 98*/
	    
	    if (perc < 0. || perc > 100.)  sf_error("Need perc in range [0.0,100.0]"); 
	    sf_sharpen_init(n1*n2,perc);

	    break;
	default:
	    sf_error("Unknown operator \"%s\"",type);
    }

    if (!sf_getint("order",&order)) order=1;
    /* accuracy order */

    predict_init (n1, n2, eps*eps, order, 1, false);

    u = sf_floatalloc3(n1,ns2,n2);
    for (i2=0; i2 < n2; i2++) {
	for (is=0; is < ns2; is++) {
	    for (i1=0; i1 < n1; i1++) {
		u[i2][is][i1] = 0.;
	    }
	}
    }

    p = sf_floatalloc2(n1,n2);
    xk = sf_floatalloc2(n1,n2);
    yk = sf_floatalloc2(n1,n2);
    trace = sf_floatalloc(n1);

    for (i3=0; i3 < n3; i3++) {
	if (verb) fprintf(stderr,"slice %d of %d\n",i3+1,n3);
	sf_floatread(p[0],n1*n2,dip);

	for (i2=0; i2 < n2; i2++) { /* loop over traces */
	    sf_floatread(trace,n1,inp);

	    for (i1=0; i1 < n1; i1++) {
		u[i2][ns][i1] = trace[i1];
	    }

	    /* predict forward */
	    for (is=0; is < ns; is++) {
		ip = i2-is-1;
		if (ip < 0) break;
		predict_step(false,false,trace,p[ip]);
		for (i1=0; i1 < n1; i1++) {
		    u[ip][ns-is-1][i1] = trace[i1];
		}
	    }

	    for (i1=0; i1 < n1; i1++) {
		trace[i1] = u[i2][ns][i1];
	    }

	    /* predict backward */
	    for (is=0; is < ns; is++) {
		ip = i2+is+1;
		if (ip >= n2) break;
		predict_step(false,true,trace,p[ip-1]);
		for (i1=0; i1 < n1; i1++) {
		    u[ip][ns+is+1][i1] = trace[i1];
		}
	    }

	}

	for(is=0; is < n2; is++) {
	    for(i1=0; i1< n1;i1++) {
		p[is][i1]=0.;
	    }
	}
	for(is=0; is < n2; is++) {
	    for(i1=0; i1 < n1; i1++) {
		fold = 0;
		for(ip=0; ip < ns; ip ++) {
		    p[is][i1] +=u[is][ip][i1];
		    if (0!=u[is][ip][i1]) fold++;
		}
		for(ip=ns+1; ip < 2*ns+1; ip ++) {
		    p[is][i1] +=u[is][ip][i1];
		    if (0!=u[is][ip][i1]) fold++;
		}
		p[is][i1] = p[is][i1]/(fold+FLT_EPSILON);
	    }
	}

	switch (type[0]) {
	    case 'd':
		for(is=0; is < n2; is++) {
		    for(i1=0; i1 < n1; i1++) {
			p[is][i1] = (p[is][i1] - u[is][ns][i1])*
			    (p[is][i1] - u[is][ns][i1]);
		    }
		}
		break;
	    case 's':
		for(is=0; is < n2; is++) {
		    for(i1=0; i1 < n1; i1++) {
			xk[is][i1] = 0.;
			yk[is][i1] = 0.;
		    }
		}
		for(nit=0; nit < niter; nit++) {
		    if (verb) sf_warning("Iteration %d of %d",nit+1,niter);

		    for(is=0; is < n2; is++) {
			for(i1=0; i1 < n1; i1++) {
			    xk[is][i1] = ((p[is][i1]-u[is][ns][i1])*u[is][ns][i1] + eps*eps*xk[is][i1])/(u[is][ns][i1]*u[is][ns][i1]+eps*eps);
			    yk[is][i1] = ((u[is][ns][i1]-p[is][i1])*p[is][i1] + eps*eps*yk[is][i1])/(p[is][i1]*p[is][i1]+eps*eps);
			}
		    }
		    sf_sharpen(xk[0]);
		    sf_weight_apply(n1*n2,xk[0]);
		    sf_sharpen(yk[0]);
		    sf_weight_apply(n1*n2,yk[0]);
		}
		for(is=0; is < n2; is++) {
		    for(i1=0; i1 < n1; i1++) {
			
			p[is][i1] = (1+xk[is][i1])*(1+yk[is][i1]);
		    }
		}
		break;
	}

	sf_floatwrite(p[0],n1*n2,out);
    }	    

    exit (0);
}
示例#8
0
文件: agent.cpp 项目: amininger/Soar
void init_soar_agent(agent* thisAgent) {

  /* JC ADDED: initialize the rhs function linked list */
  thisAgent->rhs_functions = NIL;

   /* --- initialize everything --- */
  init_symbol_tables(thisAgent);
  create_predefined_symbols(thisAgent);
  init_production_utilities(thisAgent);
  init_built_in_rhs_functions (thisAgent);
  init_rete (thisAgent);
  init_lexer (thisAgent);
  init_firer (thisAgent);
  init_decider (thisAgent);
  init_soar_io (thisAgent);
  init_chunker (thisAgent);
  init_tracing (thisAgent);
  init_explain(thisAgent);  /* AGR 564 */
  select_init(thisAgent);
  predict_init(thisAgent);

  init_memory_pool( thisAgent, &( thisAgent->gds_pool ), sizeof( goal_dependency_set ), "gds" );

  init_memory_pool( thisAgent, &( thisAgent->rl_info_pool ), sizeof( rl_data ), "rl_id_data" );
  init_memory_pool( thisAgent, &( thisAgent->rl_et_pool ), sizeof( rl_et_map ), "rl_et" );
  init_memory_pool( thisAgent, &( thisAgent->rl_rule_pool ), sizeof( rl_rule_list ), "rl_rules" );

  init_memory_pool( thisAgent, &( thisAgent->wma_decay_element_pool ), sizeof( wma_decay_element ), "wma_decay" );
  init_memory_pool( thisAgent, &( thisAgent->wma_decay_set_pool ), sizeof( wma_decay_set ), "wma_decay_set" );
  init_memory_pool( thisAgent, &( thisAgent->wma_wme_oset_pool ), sizeof( wma_pooled_wme_set ), "wma_oset" );
  init_memory_pool( thisAgent, &( thisAgent->wma_slot_refs_pool ), sizeof( wma_sym_reference_map ), "wma_slot_ref" );

  init_memory_pool( thisAgent, &( thisAgent->epmem_wmes_pool ), sizeof( epmem_wme_stack ), "epmem_wmes" );
  init_memory_pool( thisAgent, &( thisAgent->epmem_info_pool ), sizeof( epmem_data ), "epmem_id_data" );
  init_memory_pool( thisAgent, &( thisAgent->smem_wmes_pool ), sizeof( smem_wme_stack ), "smem_wmes" );
  init_memory_pool( thisAgent, &( thisAgent->smem_info_pool ), sizeof( smem_data ), "smem_id_data" );

  init_memory_pool( thisAgent, &( thisAgent->epmem_literal_pool ), sizeof( epmem_literal), "epmem_literals" );
  init_memory_pool( thisAgent, &( thisAgent->epmem_pedge_pool ), sizeof( epmem_pedge ), "epmem_pedges" );
  init_memory_pool( thisAgent, &( thisAgent->epmem_uedge_pool ), sizeof( epmem_uedge ), "epmem_uedges" );
  init_memory_pool( thisAgent, &( thisAgent->epmem_interval_pool ), sizeof( epmem_interval ), "epmem_intervals" );

  thisAgent->epmem_params->exclusions->set_value( "epmem" );
  thisAgent->epmem_params->exclusions->set_value( "smem" );

  thisAgent->smem_params->base_incremental_threshes->set_string( "10" );

#ifdef REAL_TIME_BEHAVIOR
  /* RMJ */
  init_real_time(thisAgent);
#endif


  /* --- add default object trace formats --- */
  add_trace_format (thisAgent, FALSE, FOR_ANYTHING_TF, NIL,
                    "%id %ifdef[(%v[name])]");
  add_trace_format (thisAgent, FALSE, FOR_STATES_TF, NIL,
                    "%id %ifdef[(%v[attribute] %v[impasse])]");
  { Symbol *evaluate_object_sym;
    evaluate_object_sym = make_sym_constant (thisAgent, "evaluate-object");
    add_trace_format (thisAgent, FALSE, FOR_OPERATORS_TF, evaluate_object_sym,
                      "%id (evaluate-object %o[object])");
    symbol_remove_ref (thisAgent, evaluate_object_sym);
  }
  /* --- add default stack trace formats --- */
  add_trace_format (thisAgent, TRUE, FOR_STATES_TF, NIL,
                    "%right[6,%dc]: %rsd[   ]==>S: %cs");
  add_trace_format (thisAgent, TRUE, FOR_OPERATORS_TF, NIL,
                    "%right[6,%dc]: %rsd[   ]   O: %co");

  reset_statistics (thisAgent);

  /* RDF: For gSKI */
  init_agent_memory(thisAgent);
  /* END */

}
示例#9
0
文件: agent.cpp 项目: amininger/Soar
agent * create_soar_agent (char * agent_name) {                                          /* loop index */
  char cur_path[MAXPATHLEN];   /* AGR 536 */

  //agent* newAgent = static_cast<agent *>(malloc(sizeof(agent)));
  agent* newAgent = new agent();

  newAgent->current_tc_number = 0;

  newAgent->name                               = savestring(agent_name);

  /* mvp 5-17-94 */
  newAgent->variables_set                      = NIL;

//#ifdef _WINDOWS
//  newAgent->current_line[0]                    = 0;
//  newAgent->current_line_index                 = 0;
//#endif /* _WINDOWS */

  newAgent->all_wmes_in_rete                   = NIL;
  newAgent->alpha_mem_id_counter               = 0;
  newAgent->alternate_input_string             = NIL;
  newAgent->alternate_input_suffix             = NIL;
  newAgent->alternate_input_exit               = FALSE;/* Soar-Bugs #54 */
  newAgent->backtrace_number                   = 0;
  newAgent->beta_node_id_counter               = 0;
  newAgent->bottom_goal                        = NIL;
  newAgent->changed_slots                      = NIL;
  newAgent->chunk_count                        = 1;
  newAgent->chunk_free_problem_spaces          = NIL;
  newAgent->chunky_problem_spaces              = NIL;  /* AGR MVL1 */
  strcpy(newAgent->chunk_name_prefix,"chunk");	/* ajc (5/14/02) */
  newAgent->context_slots_with_changed_acceptable_preferences = NIL;
  newAgent->current_file                       = NIL;
  newAgent->current_phase                      = INPUT_PHASE;
  newAgent->applyPhase                         = FALSE;
  newAgent->current_symbol_hash_id             = 0;
  newAgent->current_variable_gensym_number     = 0;
  newAgent->current_wme_timetag                = 1;
  newAgent->default_wme_depth                  = 1;  /* AGR 646 */
  newAgent->disconnected_ids                   = NIL;
  newAgent->existing_output_links              = NIL;
  newAgent->output_link_changed                = FALSE;  /* KJC 11/9/98 */
  /* newAgent->explain_flag                       = FALSE; */
  newAgent->go_number                          = 1;
  newAgent->go_type                            = GO_DECISION;
  newAgent->init_count                         = 0;
  newAgent->rl_init_count                      = 0;
  newAgent->grounds_tc                         = 0;
  newAgent->highest_goal_whose_context_changed = NIL;
  newAgent->ids_with_unknown_level             = NIL;
  newAgent->input_period                       = 0;     /* AGR REW1 */
  newAgent->input_cycle_flag                   = TRUE;  /* AGR REW1 */
  newAgent->justification_count                = 1;
  newAgent->lex_alias                          = NIL;  /* AGR 568 */
  newAgent->link_update_mode                   = UPDATE_LINKS_NORMALLY;
  newAgent->locals_tc                          = 0;
  newAgent->max_chunks_reached                 = FALSE; /* MVP 6-24-94 */
  newAgent->mcs_counter                        = 1;
  newAgent->memory_pools_in_use                = NIL;
  newAgent->ms_assertions                      = NIL;
  newAgent->ms_retractions                     = NIL;
  newAgent->num_existing_wmes                  = 0;
  newAgent->num_wmes_in_rete                   = 0;
  newAgent->potentials_tc                      = 0;
  newAgent->prev_top_state                     = NIL;
  newAgent->print_prompt_flag                  = TRUE;
  newAgent->printer_output_column              = 1;
  newAgent->production_being_fired             = NIL;
  newAgent->productions_being_traced           = NIL;
  newAgent->promoted_ids                       = NIL;
  newAgent->reason_for_stopping                = "Startup";
  newAgent->slots_for_possible_removal         = NIL;
  newAgent->stop_soar                          = TRUE;
  newAgent->system_halted                      = FALSE;
  newAgent->token_additions                    = 0;
  newAgent->top_dir_stack                      = NIL;   /* AGR 568 */
  newAgent->top_goal                           = NIL;
  newAgent->top_state                          = NIL;
  newAgent->wmes_to_add                        = NIL;
  newAgent->wmes_to_remove                     = NIL;
  newAgent->wme_filter_list                    = NIL;   /* Added this to avoid
															    access violation
																-AJC (5/13/02) */
  newAgent->multi_attributes                   = NIL;

  /* REW: begin 09.15.96 */

  newAgent->did_PE                             = FALSE;
  newAgent->soar_verbose_flag                  = FALSE;
  newAgent->FIRING_TYPE                        = IE_PRODS;
  newAgent->ms_o_assertions                    = NIL;
  newAgent->ms_i_assertions                    = NIL;

  /* REW: end   09.15.96 */

  newAgent->postponed_assertions			   = NIL;

  /* REW: begin 08.20.97 */
  newAgent->active_goal                        = NIL;
  newAgent->active_level                       = 0;
  newAgent->previous_active_level              = 0;

  /* Initialize Waterfall-specific lists */
  newAgent->nil_goal_retractions               = NIL;
  /* REW: end   08.20.97 */

  /* REW: begin 10.24.97 */
  newAgent->waitsnc                            = FALSE;
  newAgent->waitsnc_detect                     = FALSE;
  /* REW: end   10.24.97 */

  /* Initializing rete stuff */
  for (int i=0; i < 256; i++) {
     newAgent->actual[i]=0;
     newAgent->if_no_merging[i]=0;
     newAgent->if_no_sharing[i]=0;
  }

  /* Initializing lexeme */
  newAgent->lexeme.type = NULL_LEXEME;
  newAgent->lexeme.string[0] = 0;
  newAgent->lexeme.length = 0;
  newAgent->lexeme.int_val = 0;
  newAgent->lexeme.float_val = 0.0;
  newAgent->lexeme.id_letter = 'A';
  newAgent->lexeme.id_number = 0;

  reset_max_stats(newAgent);

  newAgent->real_time_tracker = 0;
  newAgent->attention_lapse_tracker = 0;

  if(!getcwd(cur_path, MAXPATHLEN))
    print(newAgent, "Unable to set current directory while initializing agent.\n");
  newAgent->top_dir_stack = static_cast<dir_stack_struct *>(malloc(sizeof(dir_stack_struct)));   /* AGR 568 */
  newAgent->top_dir_stack->directory = static_cast<char *>(malloc(MAXPATHLEN*sizeof(char)));   /* AGR 568 */
  newAgent->top_dir_stack->next = NIL;   /* AGR 568 */
  strcpy(newAgent->top_dir_stack->directory, cur_path);   /* AGR 568 */

  /* changed all references of 'i', a var belonging to a previous for loop, to 'productionTypeCounter' to be unique
    stokesd Sept 10 2004*/
  for (int productionTypeCounter=0; productionTypeCounter<NUM_PRODUCTION_TYPES; productionTypeCounter++) {
    newAgent->all_productions_of_type[productionTypeCounter] = NIL;
    newAgent->num_productions_of_type[productionTypeCounter] = 0;
  }

  newAgent->o_support_calculation_type = 4; /* KJC 7/00 */ // changed from 3 to 4 by voigtjr  (/* bugzilla bug 339 */)
  newAgent->numeric_indifferent_mode = NUMERIC_INDIFFERENT_MODE_SUM;

  /* JC ADDED: Make sure that the RHS functions get initialized correctly */
  newAgent->rhs_functions = NIL;

  // JRV: Allocates data for XML generation
  xml_create( newAgent );

  soar_init_callbacks( newAgent );

  //
  // This call is needed to set up callbacks.
  init_memory_utilities(newAgent);

  //
  // This was moved here so that system parameters could
  // be set before the agent was initialized.
  init_sysparams (newAgent);

  /* Initializing all the timer structures */
  // Timers must be initialized after sysparams
#ifndef NO_TIMING_STUFF
  newAgent->timers_cpu.set_enabled(&(newAgent->sysparams[TIMERS_ENABLED]));
  newAgent->timers_kernel.set_enabled(&(newAgent->sysparams[TIMERS_ENABLED]));
  newAgent->timers_phase.set_enabled(&(newAgent->sysparams[TIMERS_ENABLED]));
#ifdef DETAILED_TIMING_STATS
  newAgent->timers_gds.set_enabled(&(newAgent->sysparams[TIMERS_ENABLED]));
#endif
  reset_timers(newAgent);
#endif

  // dynamic memory pools (should come before consumers of dynamic pools)
  newAgent->dyn_memory_pools = new std::map< size_t, memory_pool* >();

  // dynamic counters
  newAgent->dyn_counters = new std::map< std::string, uint64_t >();

  // exploration initialization
  newAgent->exploration_params[ EXPLORATION_PARAM_EPSILON ] = exploration_add_parameter( 0.1, &exploration_validate_epsilon, "epsilon" );
  newAgent->exploration_params[ EXPLORATION_PARAM_TEMPERATURE ] = exploration_add_parameter( 25, &exploration_validate_temperature, "temperature" );

  // rl initialization
  newAgent->rl_params = new rl_param_container( newAgent );
  newAgent->rl_stats = new rl_stat_container( newAgent );
  newAgent->rl_prods = new rl_production_memory();

  rl_initialize_template_tracking( newAgent );

  // select initialization
  newAgent->select = new select_info;
  select_init( newAgent );


  // predict initialization
  newAgent->prediction = new std::string();
  predict_init( newAgent );


  // wma initialization
  newAgent->wma_params = new wma_param_container( newAgent );
  newAgent->wma_stats = new wma_stat_container( newAgent );
  newAgent->wma_timers = new wma_timer_container( newAgent );

#ifdef USE_MEM_POOL_ALLOCATORS
  newAgent->wma_forget_pq = new wma_forget_p_queue( std::less< wma_d_cycle >(), soar_module::soar_memory_pool_allocator< std::pair< wma_d_cycle, wma_decay_set* > >( newAgent ) );
  newAgent->wma_touched_elements = new wma_pooled_wme_set( std::less< wme* >(), soar_module::soar_memory_pool_allocator< wme* >( newAgent ) );
  newAgent->wma_touched_sets = new wma_decay_cycle_set( std::less< wma_d_cycle >(), soar_module::soar_memory_pool_allocator< wma_d_cycle >( newAgent ) );
#else
  newAgent->wma_forget_pq = new wma_forget_p_queue();
  newAgent->wma_touched_elements = new wma_pooled_wme_set();
  newAgent->wma_touched_sets = new wma_decay_cycle_set();
#endif
  newAgent->wma_initialized = false;
  newAgent->wma_tc_counter = 2;


  // epmem initialization
  newAgent->epmem_params = new epmem_param_container( newAgent );
  newAgent->epmem_stats = new epmem_stat_container( newAgent );
  newAgent->epmem_timers = new epmem_timer_container( newAgent );

  newAgent->epmem_db = new soar_module::sqlite_database();
  newAgent->epmem_stmts_common = NULL;
  newAgent->epmem_stmts_graph = NULL;

  newAgent->epmem_node_mins = new std::vector<epmem_time_id>();
  newAgent->epmem_node_maxes = new std::vector<bool>();

  newAgent->epmem_edge_mins = new std::vector<epmem_time_id>();
  newAgent->epmem_edge_maxes = new std::vector<bool>();
  newAgent->epmem_id_repository = new epmem_parent_id_pool();
  newAgent->epmem_id_replacement = new epmem_return_id_pool();
  newAgent->epmem_id_ref_counts = new epmem_id_ref_counter();

  // debug module settings
  newAgent->debug_params = new debug_param_container( newAgent );

  #ifdef USE_MEM_POOL_ALLOCATORS
  newAgent->epmem_node_removals = new epmem_id_removal_map( std::less< epmem_node_id >(), soar_module::soar_memory_pool_allocator< std::pair< epmem_node_id, bool > >( newAgent ) );
  newAgent->epmem_edge_removals = new epmem_id_removal_map( std::less< epmem_node_id >(), soar_module::soar_memory_pool_allocator< std::pair< epmem_node_id, bool > >( newAgent ) );

  newAgent->epmem_wme_adds = new epmem_symbol_set( std::less< Symbol* >(), soar_module::soar_memory_pool_allocator< Symbol* >( newAgent ) );
  newAgent->epmem_promotions = new epmem_symbol_set( std::less< Symbol* >(), soar_module::soar_memory_pool_allocator< Symbol* >( newAgent ) );

  newAgent->epmem_id_removes = new epmem_symbol_stack( soar_module::soar_memory_pool_allocator< Symbol* >( newAgent ) );
#else
  newAgent->epmem_node_removals = new epmem_id_removal_map();
  newAgent->epmem_edge_removals = new epmem_id_removal_map();

  newAgent->epmem_wme_adds = new epmem_symbol_set();
  newAgent->epmem_promotions = new epmem_symbol_set();

  newAgent->epmem_id_removes = new epmem_symbol_stack();
#endif

  newAgent->epmem_validation = 0;

  // smem initialization
  newAgent->smem_params = new smem_param_container( newAgent );
  newAgent->smem_stats = new smem_stat_container( newAgent );
  newAgent->smem_timers = new smem_timer_container( newAgent );

  newAgent->smem_db = new soar_module::sqlite_database();

  newAgent->smem_validation = 0;

#ifdef USE_MEM_POOL_ALLOCATORS
  newAgent->smem_changed_ids = new smem_pooled_symbol_set( std::less< Symbol* >(), soar_module::soar_memory_pool_allocator< Symbol* >( newAgent ) );
#else
  newAgent->smem_changed_ids = new smem_pooled_symbol_set();
#endif
  newAgent->smem_ignore_changes = false;

  // statistics initialization
  newAgent->dc_stat_tracking = false;
  newAgent->stats_db = new soar_module::sqlite_database();

  newAgent->substate_break_level = 0;

  return newAgent;
}