I'm writing a program based on the multi-chain Metropolis algorithm to find minimum energy parameters for a given function. This program basically runs two times:
- First multi-chain burn-in run which sweeps the parameter space and stops when a given convergence criteria is met;
- Exploratory run which samples the various parameter possibilities around the convergence points calculated in the first step but only with one chain.
For each chain I save all the parameters it passed through and its corresponding energy. Each step of each chain runs (among other things) the following code:
int Step(double * current_energy, vector<double> & energy){
energy.push_back(current_energy);
return 0;
}
The problem is that for the first part of the program, I'm storing the energies in a
vector< vector<double> > burn_energy;
to allow me to save multiple series of energies in just one place. In the second part, I store the energies in
vector<double> explore_energy;
because I only have to save one series of energy.
The problem arises when I have to call these steps. For the first part I would call them this way:
Step(& current_energy[j], burn_energy[j]);
in which j indicates the number of the chain. In the second part, as there is only one chain, the call would be something like:
Step(& current_energy, explore_energy);
I can't see what is wrong with my implementation but XCode gives me the following error in the first part:
error: no matching function for call to 'std::vector<double, std::allocator<double> >::push_back(double*&)'
Is this an error with the passing of the vector energy or the element of the array current_energy?