“error:passing 'const std::vector<int>' as 'this' argument discards qualifiers [-fpermissive]”
Managed C++/CLI
1
Posts
1
Posters
4
Views
1
Watching
-
I am trying to apply DESPOT POMDP solver with using given examples to build my own decision making problem and I followed the documentation in the repository to build different relevant classes and functions in the header file
class SimpleState: public State {
public:
int position;
int context;
int time;SimpleState(); SimpleState(int \_position, int \_context, int \_time) : rat\_position(\_position), context(\_context), time(\_time) { } SimpleState(int \_state\_id); ~SimpleState(); std::string text() const; }; SimpleState::SimpleState() { } class StarMazeProblem : public DSPOMDP, public MDP { protected: std::vector > > transition\_probabilities\_; //state, action, \[state, weight\] mutable MemoryPool memory\_pool\_; std::vector states\_; mutable std::vector mdp\_policy\_; public: enum {CENTER = 0, RIGHT = 1, LEFT = 2}; public: StarMazeProblem(); int NumStates() const; void ComputeDefaultActions(std::string type) const; ParticleUpperBound\* CreateParticleUpperBound(std::string name = "DEFAULT") const;//? ScenarioUpperBound\* CreateScenarioUpperBound(std::string name = "DEFAULT", std::string particle\_bound\_name = "DEFAULT") const; ScenarioLowerBound\* CreateScenarioLowerBound(std::string name = "DEFAULT", std::string particle\_bound\_name = "DEFAULT") const; }
and in the `starmaze.cpp` file the relevant lines are
int StarMazeProblem::NumStates() const {
return CONTEXT * POSITIONS * TIME;
}
void StarMazeProblem::ComputeDefaultActions(string type) const {
cerr << "Default action = " << type << endl;
if (type == "MDP") {
const_cast(this)->ComputeOptimalPolicyUsingVI();
int num_states = NumStates();
default_action_.resize(num_states);double value = 0; for (int s = 0; s < num\_states; s++) { default\_action\_\[s\] = policy\_\[s\].action; value += policy\_\[s\].value; } } else { cerr << "Unsupported default action type " << type << endl; exi