Example #1
0
void MCTS::AddTransforms(VNODE *root, BELIEF_STATE &beliefs) {
    int attempts = 0, added = 0;

    // Local transformations of state that are consistent with history
    while (added < Params.NumTransforms && attempts < Params.MaxAttempts) {
        STATE *transform = CreateTransform();
        if( transform ) {
            beliefs.AddSample(transform);
            added++;
        }
        attempts++;
    }

    if( Params.Verbose >= 1 ) {
        cout << "Created " << added << " local transformations out of " << attempts << " attempts" << endl;
    }
}
Example #2
0
void FlatMCTS::ParticleFilter(BELIEF_STATE &beliefs)  // unweighted particle filter
{
  int attempts = 0, added = 0;
  int max_attempts = (Params.NumStartStates - beliefs.GetNumSamples()) * 10;

  int realObs = History.Back().Observation;
  int stepObs;
  double stepReward;

  if (Params.Verbose >= 1) {
    cout << "MCTS::ParticleFilter: last step belief size "
    << Root->Beliefs().GetNumSamples() << ", current belief size "
    << beliefs.GetNumSamples() << endl;
  }

  while (beliefs.GetNumSamples() < Params.NumStartStates &&
         attempts < max_attempts) {
    STATE *state = Root->Beliefs().CreateSample(Simulator);
    Simulator.Step(*state, History.Back().Action, stepObs, stepReward);
    if (Params.ThompsonSampling) {
      Root->Child(History.Back().Action).Update(stepObs, stepReward);
    }

    if (stepObs == realObs) {
      beliefs.AddSample(state);
      added++;
    } else {
      Simulator.FreeState(state);
    }
    attempts++;
  }

  if (Params.Verbose >= 1) {
    cout << "MCTS::ParticleFilter: Created " << added
    << " local transformations out of " << attempts << " attempts" << endl;
  }
}
Example #3
0
void FlatMCTS::AddTransforms(BELIEF_STATE &beliefs) {
  int attempts = 0, added = 0;

  if (Params.Verbose >= 1) {
    cout << "MCTS::AddTransforms: last step belief size "
    << Root->Beliefs().GetNumSamples() << ", current belief size "
    << beliefs.GetNumSamples() << endl;
  }

  // Local transformations of state that are consistent with history
  while (added < Params.NumTransforms && attempts < Params.MaxAttempts) {
    STATE *transform = CreateTransform();
    if (transform) {
      beliefs.AddSample(transform);
      added++;
    }
    attempts++;
  }

  if (Params.Verbose >= 1) {
    cout << "MCTS::AddTransforms: Created " << added
    << " local transformations out of " << attempts << " attempts" << endl;
  }
}