31     DisplayProblem1D::DisplayProblem1D(): MatPlot()
    36     void DisplayProblem1D::init(BayesOptBase* bopt, 
size_t dim)
    40       throw std::invalid_argument(
"Display only works for 1D problems"); 
    44       bopt->initializeOptimization();
    45       size_t n_points = bopt->getData()->getNSamples();
    46       for (
size_t i = 0; i<n_points;++i)
    48       const double res = bopt->getData()->getSampleY(i);
    49       const vectord last = bopt->getData()->getSampleX(i);
    51       lx.push_back(last(0));
    57     void DisplayProblem1D::setSTEP()
    59       if (status != NOT_READY)
    65     void DisplayProblem1D::toogleRUN()
    67       if (status != NOT_READY)
    80     void DisplayProblem1D::DISPLAY()
    82       if (status != NOT_READY)
    84       size_t nruns = bopt_model->getParameters()->n_iterations;
    85       if ((status != STOP) && (state_ii < nruns))
    89           bopt_model->stepOptimization(); 
    90           const double res = bopt_model->getData()->getLastSampleY();
    91           const vectord last = bopt_model->getData()->getLastSampleX();
    93           lx.push_back(last(0));
    95           if (status == STEP) { status = STOP; }
   100       std::vector<double> x,y,z,su,sl,c;
   102       y = x; z = x; su = x; sl = x; c = x;
   106       for(
size_t i=0; i<n; ++i)
   109           ProbabilityDistribution* pd = bopt_model->getPrediction(q);
   110           y[i] = pd->getMean();                                
   111           su[i] = y[i] + 2*pd->getStd();                       
   112           sl[i] = y[i] - 2*pd->getStd();                       
   113           c[i] = -bopt_model->evaluateCriteria(q);             
   114           z[i] = bopt_model->evaluateSample(q);                
   119       title(
"Press r to run and stop, s to run a step and q to quit.");
   121       plot(lx,ly);
set(
"k");
set(
"o");
set(4);         
   122       plot(x,su);
set(
"g"); 
set(2);                  
   123       plot(x,sl);
set(
"g"); 
set(2);
   124       plot(x,z);
set(
"r"); 
set(3);                   
   132     DisplayProblem2D::DisplayProblem2D(): 
   133       MatPlot(), cx(1), cy(1), c_points(100), cX(c_points),
   134       cY(c_points), cZ(c_points,
std::vector<double>(c_points))
   139     void DisplayProblem2D::setSolution(vectord sol)
   141       solx.push_back(sol(0));
   142       soly.push_back(sol(1));
   145     void DisplayProblem2D::prepareContourPlot()
   147       cX=linspace(0,1,c_points);
   148       cY=linspace(0,1,c_points);
   150       for(
int i=0;i<c_points;++i)
   152       for(
int j=0;j<c_points;++j)
   155           q(0) = cX[j]; q(1) = cY[i];
   156           cZ[i][j]= bopt_model->evaluateSample(q);
   161     void DisplayProblem2D::init(BayesOptBase* bopt, 
size_t dim)
   165       throw std::invalid_argument(
"This display only works "   170       prepareContourPlot();
   172       bopt->initializeOptimization();
   173       size_t n_points = bopt->getData()->getNSamples();
   174       for (
size_t i = 0; i<n_points;++i)
   176       const vectord last = bopt->getData()->getSampleX(i);
   177       lx.push_back(last(0));
   178       ly.push_back(last(1));
   184     void DisplayProblem2D::setSTEP()
   186       if (status != NOT_READY)
   192     void DisplayProblem2D::toogleRUN()
   194       if (status != NOT_READY)
   207     void DisplayProblem2D::DISPLAY()
   209       if (status != NOT_READY)
   211       size_t nruns = bopt_model->getParameters()->n_iterations;
   212       title(
"Press r to run and stop, s to run a step and q to quit.");
   213       contour(cX,cY,cZ,50);                         
   214       plot(cx,cy);
set(
"g");
set(
"o");
set(4);         
   215       plot(solx,soly);
set(
"r"); 
set(
"o");
set(4);    
   217       if ((status != STOP) && (state_ii < nruns))
   221           bopt_model->stepOptimization(); 
   222           const vectord last = bopt_model->getData()->getLastSampleX();
   229           plot(lx,ly);
set(
"k");
set(
"o");
set(4);         
   232           lx.push_back(last(0));
   233           ly.push_back(last(1));
   235           if (status == STEP) { status = STOP; }
   239           plot(lx,ly);
set(
"k");
set(
"o");
set(4);         
 
Namespace of the library interface. 
Plots the evolution (nonparametric process, criteria or contour plots) of 1D and 2D problems...
Interface for probability models.