double operator() (const vectord &x) { ProbabilityDistribution* d = mProc->prediction(x); double mu = d->getMean(); double sigma2 = d->getStd() * d->getStd(); return mu + mSqAlpha * (sqrt(sigma2+mGamma) - sqrt(mGamma)); };
void update(const vectord &x) { ProbabilityDistribution* d = mProc->prediction(x); double mu = d->getMean(); double sigma2 = d->getStd() * d->getStd(); mGamma += sigma2; }
void DisplayProblem1D::DISPLAY() { if (status != NOT_READY) { size_t nruns = bopt_model->getParameters()->n_iterations; if ((status != STOP) && (state_ii < nruns)) { // We are moving. Next iteration ++state_ii; bopt_model->stepOptimization(); const double res = bopt_model->getData()->getLastSampleY(); const vectord last = bopt_model->getData()->getLastSampleX(); ly.push_back(res); lx.push_back(last(0)); if (status == STEP) { status = STOP; } } // We compute the prediction, true value and criteria at 1000 points int n=1000; std::vector<double> x,y,z,su,sl,c; x = linspace(0,1,n); y = x; z = x; su = x; sl = x; c = x; // Query functions at the 1000 points vectord q(1); for(size_t i=0; i<n; ++i) { q(0) = x[i]; // Query ProbabilityDistribution* pd = bopt_model->getPrediction(q); y[i] = pd->getMean(); //Expected value su[i] = y[i] + 2*pd->getStd(); //Upper bound (95 %) sl[i] = y[i] - 2*pd->getStd(); //Lower bound (95 %) c[i] = -bopt_model->evaluateCriteria(q); //Criteria value z[i] = bopt_model->evaluateSample(q); //Target function true value } //GP subplot subplot(2,1,1); title("Press r to run and stop, s to run a step and q to quit."); plot(x,y); set(3); // Expected value in default color (blue) plot(lx,ly);set("k");set("o");set(4); // Data points as black star plot(x,su);set("g"); set(2); // Uncertainty as green lines plot(x,sl);set("g"); set(2); plot(x,z);set("r"); set(3); // True function as red line //Criterion subplot subplot(2,1,2); plot(x,c); set(3); } };