Ejemplo n.º 1
0
    void expandSuccessors(Node c)
    {
        int i,d,g,h;
        Node t;
        P_II jp;
        V_PII nbs=neighbourPrune(c);
        for (i=0; i<nbs.size(); i++)
        {
            jp=checkJump(nbs[i],c.pos);
            if (jp.first != -1)
            {
                if (mazer.isInVis(jp) == true)
                    continue;
                d=abs(jp.first-c.pos.first)+abs(jp.second-c.pos.second);
                g=c.g+d;
                if (mazer.isInQue(jp) == false || g < mem_g[jp.first][jp.second])
                {
                    mem_g[jp.first][jp.second]=g;
                    t.g=g;
                    h=abs(jp.first-end.first)+abs(jp.second-end.second);
                    t.f=t.g+h;
                    t.pos=jp;
                   // printf("%d %d %d %d %d %d\n",t.pos.first,t.pos.second,t.parent.first,t.parent.second,c.pos.first,c.pos.second);
                    t.parent=c.pos;


                    if (mazer.isInQue(jp) == false)
                    {
                        path[jp.first][jp.second]=c.pos;
                        pri_List.push(t);
                        mazer.pushQue(t.pos);
                    }
                    else
                    {
                        pri_List.update(t);
                    }
                }

            }
        }
    }
Ejemplo n.º 2
0
 int findPath()
 {
     init();
     Node s=Node(sta,0,0,make_pair(-1,-1)),tmp;
     pri_List.push(s);
     mazer.pushQue(s.pos);
     while (!pri_List.empty())
     {
         tmp=pri_List.top();
         printf("%d %d %d %d %d\n",tmp.pos.first,tmp.pos.second,tmp.parent.first,tmp.parent.second,tmp.f);
         mazer.pushVis(tmp.pos);
         pri_List.pop();
         if (tmp.pos == end)
         {
             backtrace(end.first,end.second);
             return 1;
         }
         expandSuccessors(tmp);
     }
     return 0;
 }
Ejemplo n.º 3
0
int main()
{

	ifstream fin1("fhb.txt");

	// Allocate memory on the heap due to large
	// data set
	double *dptr = new double[numSamples];

	for (int i = 0; i < numSamples; i++) {

		 fin1 >> *(dptr + i);
	 }
	 
	 fin1.close();

	 ifstream fin2("mhb.txt");

	 // Allocate memory on the heap due to large
	 // data set
	 double *mptr = new double[numSamples];

	 for (int i = 0; i < numSamples; i++) {

		 fin2 >> *(mptr + i);
	 }

	 fin2.close();

	// Instantiate NodeList Objects
    	NodeList noiseNode;
	NodeList filterCoeffs;

	// Node pointers to head nodes
	Node * f = filterCoeffs.head;
	Node * n = noiseNode.head;

	// Output of filter
	double* yptr = new double[numSamples];

	// Error signal between reference signal and desired+noise signal
	double* eptr = new double [numSamples];

	// Simulation Loop
	int j = 0;

	while (j < numSamples) {
		//Push a single measurement to stream
		n = noiseNode.push( *(mptr + k) ); 

		//Filter measurements
		*(yptr+j) = filter(f, n);

		//Adaptive Filter Error
		*(eptr+j) = *(dptr + k) - *(yptr+j);

		//Update Filter Coefficients, 
		//output head node of coefficient stream
		f = adapt(f, n, *(eptr+j));

		j++;
	}

	// Spool data to text file 
	ofstream myfile;
	myfile.open("yout.txt");
	myfile << "error" << setw(15) << "\n";


	for (int i = 0; i < numSamples; i++) {

		// Capture output, y, to file
		myfile << *(eptr+i) << "\n";

	}
	
	myfile.close();

	return 0; 


}