示例#1
0
/**************************************************************************************************
 *                              Solution creation
 * ***********************************************************************************************/
Game::Game Solver::PddlBaseClass::getSolution(){


    createDomainFile("/tmp/domain.txt");


    createProblemFile("/tmp/problem.txt");



    startSolver("/tmp/domain.txt", "/tmp/problem.txt", "/tmp/ausg.txt");

    readSolution("/tmp/ausg.txt");
    return gameField;
}
示例#2
0
//static
void
GradientsBase::solveImage(imageType_t const &rLaplaceImage_p, imageType_t &rSolution_p)
{
  int const nRows=rLaplaceImage_p.Height();
  int const nCols=rLaplaceImage_p.Width();
  int const nChannels=rLaplaceImage_p.NumberOfChannels();
  imageType_t::color_space colorSpace=rLaplaceImage_p.ColorSpace();

#ifdef USE_FFTW
  // adapted from http://www.umiacs.umd.edu/~aagrawal/software.html,

  AssertColImage(rLaplaceImage_p);
  // just in case we accidentally change this, because code below believes in double...
  Assert(typeid(realType_t)==typeid(double));
  // check assumption of row major format
  Assert(rLaplaceImage_p.PixelAddress(0,0)+1==rLaplaceImage_p.PixelAddress(1,0));


  rSolution_p.AllocateData(nCols,nRows,nChannels,colorSpace);
  rSolution_p.ResetSelections();
  rSolution_p.Black();

#ifdef USE_THREADS
    // threaded version
    int const nElements=nRows*nCols;
    int const nThreads=Thread::NumberOfThreads(nElements);

    if(fftw_init_threads()==0){
      throw Error("Problem initilizing threads");
    }
    fftw_plan_with_nthreads(nThreads);
#endif

  for(int chan=0;chan<nChannels;++chan){
    TimeMessage startSolver(String("FFTW Solver, Channel ")+String(chan));

    // FIXME see if fttw_allocate gives us something...
    imageType_t fcos(nCols,nRows);

#if 0
    // During experiment, the higher optimization did not give us anything except for an additional delay. May change later.
    fftw_plan pForward= fftw_plan_r2r_2d(nRows, nCols, const_cast<double *>(rLaplaceImage_p.PixelData(chan)), fcos.PixelData(), FFTW_REDFT10, FFTW_REDFT10, FFTW_MEASURE);
    fftw_plan pInverse = fftw_plan_r2r_2d(nRows, nCols, fcos.PixelData(), rSolution_p.PixelData(chan), FFTW_REDFT01, FFTW_REDFT01, FFTW_ESTIMATE);
#else
    fftw_plan pForward= fftw_plan_r2r_2d(nRows, nCols, const_cast<double *>(rLaplaceImage_p.PixelData(chan)), fcos.PixelData(), FFTW_REDFT10, FFTW_REDFT10, FFTW_MEASURE);
    fftw_plan pInverse = fftw_plan_r2r_2d(nRows, nCols, fcos.PixelData(), rSolution_p.PixelData(chan), FFTW_REDFT01, FFTW_REDFT01, FFTW_ESTIMATE);
#endif

    // find DCT
    fftw_execute(pForward);

    realType_t const pi=pcl::Pi();

    for(int row = 0 ; row < nRows; ++row){
      for(int col = 0 ; col < nCols; ++col){
	fcos.Pixel(col,row) /= 2*cos(pi*col/( (double) nCols)) - 2 + 2*cos(pi*row/((double) nRows)) - 2;
      }
    }
    fcos.Pixel(0,0)=0.0;

    // Inverse DCT
    fftw_execute(pInverse);
    fftw_destroy_plan(pForward);
    fftw_destroy_plan(pInverse);
  }
#endif
#ifdef USE_PIFFT
  // use PI FFT based solver by Carlos Milovic F.
  rLaplaceImage_p.ResetSelections();
  rSolution_p.AllocateData(nCols,nRows,nChannels,colorSpace);
  rSolution_p.ResetSelections();
  // current solver handles only one channel per run.
  for(int chan=0;chan<nChannels;++chan){
    TimeMessage startSolver(String("PIFFT Solver, Channel ")+String(chan));
    imageType_t tmpImage(nCols,nRows);
    rLaplaceImage_p.SelectChannel(chan);
    tmpImage.Assign(rLaplaceImage_p);
    __SolvePoisson(tmpImage);
    rSolution_p.SelectChannel(chan);
    rSolution_p.Mov(tmpImage);
  }
#endif
}