Exemple #1
0
TrainingSet::TrainingSet(double **inputs,
						 unsigned int sinputs,
						 double **targets,
						 unsigned int stargets,
						 unsigned int spatterns, QObject *parent) :
	QObject(parent)
{
	vector<vector<double> >
			tinputs(spatterns),
			ttargets(spatterns);

	for(unsigned int i = 0; i < spatterns; i++){
		tinputs[i] = vector<double>(inputs[i], inputs[i] + sinputs);
		ttargets[i] = vector<double>(targets[i], targets[i] + stargets);
	}
	initTS(tinputs, ttargets);
}
Exemple #2
0
TrainingSet::TrainingSet(int inputsize, double targetsize, int n, QObject *parent) :
	QObject(parent)
{
	initTS(vector<vector<double> > (n, vector<double>(inputsize, 0)), vector<vector<double> >(n, vector<double>(targetsize, 0)));
}
Exemple #3
0
TrainingSet::TrainingSet(const TrainingSet &ts, QObject *parent) :
	QObject(parent)
{
	initTS(ts.getInputs(), ts.getTargets());
}
Exemple #4
0
TrainingSet::TrainingSet(QObject *parent) :
	QObject(parent)
{
	initTS(vector<vector<double> > (1, vector<double>(1, 0)), vector<vector<double> >(1, vector<double>(1, 0)));
}
Exemple #5
0
TrainingSet::TrainingSet(const vector<vector<double> > &inputs, const vector<vector<double> > &targets, QObject *parent) :
	QObject(parent)
{
	initTS(inputs, targets);
}
//=============================================================================
// calcSCC(DICE *dice1, BORG_Solution solution)
//
// Calculate the social cost of carbon in *dice1 using the provided
// BORG solution
//
//=============================================================================
void calcSCC(DICE *dice1, BORG_Solution solution)
{	
  // Make a temporary dice object
  DICE dice2;
  DICE *dice2ptr = &dice2;

  // Initialize a CDICE model run
  allocateConfig(dice2ptr);
  allocateCtrl(dice2ptr);
  allocateDvars(dice2ptr);
  ctrl_CDICE(dice2ptr, "cdice_control.txt");
  allocateCarb(dice2ptr);
  allocateClim(dice2ptr);
  allocateEcon(dice2ptr);
  allocateLims(dice2ptr);
  initTS(dice2ptr);
  
  if(dice1->ctrl.use_doeclim == 1) {
    doeclim_load_hind_forc(dice2ptr);
  }
  
  // Make temporary variables to hold the changes in utility
  double dutil_e;
  double dutil_c;
  int i;
  int t;
  int tsub;
  
  // Assign this control policy to the temp dice object
  for(i=0; i<dice2ptr->ctrl.nvars; i++) {
    if(i < 59) {
    	if(dice1->ctrl.policy_inertia > 0.0) {
    		dice1->dvars.miu[i+1] = dice1->dvars.miu[i] + (BORG_Solution_get_variable(solution, i) * dice1->ctrl.policy_inertia);
	      dice2ptr->dvars.miu[i+1] = dice2ptr->dvars.miu[i] + (BORG_Solution_get_variable(solution, i) * dice2ptr->ctrl.policy_inertia);
	    }
	    else {
      dice1->dvars.miu[i+1] = BORG_Solution_get_variable(solution, i);
      dice2ptr->dvars.miu[i+1] = BORG_Solution_get_variable(solution, i);
      }
    }
    else {
      dice1->dvars.s[i-59] = BORG_Solution_get_variable(solution, i);
      dice2ptr->dvars.s[i-59] = BORG_Solution_get_variable(solution, i);
    }
  }
  
  // Run the model over the dice object
  calc_CDICE(dice1);
  
  // Pass the updated configuration parameters to
  // the temp dice object
  if(dice1->ctrl.use_doeclim == 1) {
    dice2ptr->clim.t2co = dice1->clim.t2co;
    dice2ptr->clim.kappa = dice1->clim.kappa;
    dice2ptr->clim.alpha = dice1->clim.alpha;
    doeclim_DICE_init(dice2ptr);
  }
  else {
    dice2ptr->clim.t2xco2 = dice1->clim.t2xco2;
  }
  
  // Loop over the available time steps
  for(t=1; t<dice1->config.nPeriods; t++) {
    
    // Reset the temp dice object
    calc_CDICE(dice2ptr);
    
    // Increment the consumption at this time step
    dice2ptr->econ.c[t-1] += 1.0;
    
    // Do the post processing of this run
    postProcess(dice2ptr);
    
    // Store the utility from this run
    dutil_c = dice2ptr->econ.utility - dice1->econ.utility;
    
    // Reset the consumption
    dice2ptr->econ.c[t-1] = dice1->econ.c[t-1];        
    
    // Increment the emissions at this time step
    dice2ptr->econ.e[t-1] += 1.0;
    
    // Run the model on the temporary dice object
    for(tsub=t; tsub<dice1->config.nPeriods; tsub++) {
      calcCarb(dice2ptr, tsub);
      if(dice2ptr->ctrl.use_doeclim) {
	doeclim_dice_ts(dice2ptr, tsub);
      }
      else {
	calcClim(dice2ptr, tsub);
      }
      calcEcon(dice2ptr, tsub);
    }
    
    // Do the post processing of this run
    postProcess(dice2ptr);
    
    // Store the utility from this run
    dutil_e = dice2ptr->econ.utility - dice1->econ.utility;
    
    // Calculate the SCC from these differences in utility
    dice1->econ.scc[t-1] = -1000.0 * (dutil_e / dutil_c);
  }
  
  // Delete the temporary DICE object
  free_CDICE(dice2ptr);
  
  return;
}