D
dvir
Hi
I have a runing error while trying to initialize a class.
this is my code:
main.C
-------------
#include "tdagent.H"
#include "simple_env.H"
#include <vector>
int main()
{
simple_env *env;
env = new simple_env();
env->create();
tdagent *agent;
agent = new tdagent(env);
....
}
tdagent.H
------------------
#ifndef TDGAENT_H
#define TDAGENT_H
#include "critic.H"
#include "actor.H"
#include "simple_env.H"
class tdagent
{
private:
ublas::vector<float> get_state();
ublas::vector<float> get_previous_state();
void set_previous_state(ublas::vector<float> curr_state);
float get_reward();
simple_env* env;
critic* critic1;
actor* actor1;
float d;
state x;
public:
tdagent(simple_env* environment);
~tdagent();
std::vector<float> find_next_action();
};
#endif
tdagent.C
------------------
#include "tdagent.H"
tdagent::tdagent(simple_env* env)
: critic1(new critic(env->get_cov(),env->get_state())),
actor1(new actor(env->get_cov(),env->get_state(),
env->get_actions_num(),
env->get_min_reward(),env->get_max_reward()))
{
x.prev=get_state();
}
.....
The code compiled fine.
But when I tried to run it I got:
"Aborted (core dumped)"
I tried to debug it using ddd, and I saw that the program exits at:
"agent = new tdagent(env);"
at main.C
when trying to step into this function I get to
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iostream
I'm using Cygwin g++ 3.4.4
I don't understand where is my mistake.
Hope you can help me find it.
Thanks for your help.
Dvir.
I have a runing error while trying to initialize a class.
this is my code:
main.C
-------------
#include "tdagent.H"
#include "simple_env.H"
#include <vector>
int main()
{
simple_env *env;
env = new simple_env();
env->create();
tdagent *agent;
agent = new tdagent(env);
....
}
tdagent.H
------------------
#ifndef TDGAENT_H
#define TDAGENT_H
#include "critic.H"
#include "actor.H"
#include "simple_env.H"
class tdagent
{
private:
ublas::vector<float> get_state();
ublas::vector<float> get_previous_state();
void set_previous_state(ublas::vector<float> curr_state);
float get_reward();
simple_env* env;
critic* critic1;
actor* actor1;
float d;
state x;
public:
tdagent(simple_env* environment);
~tdagent();
std::vector<float> find_next_action();
};
#endif
tdagent.C
------------------
#include "tdagent.H"
tdagent::tdagent(simple_env* env)
: critic1(new critic(env->get_cov(),env->get_state())),
actor1(new actor(env->get_cov(),env->get_state(),
env->get_actions_num(),
env->get_min_reward(),env->get_max_reward()))
{
x.prev=get_state();
}
.....
The code compiled fine.
But when I tried to run it I got:
"Aborted (core dumped)"
I tried to debug it using ddd, and I saw that the program exits at:
"agent = new tdagent(env);"
at main.C
when trying to step into this function I get to
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/iostream
I'm using Cygwin g++ 3.4.4
I don't understand where is my mistake.
Hope you can help me find it.
Thanks for your help.
Dvir.