Skip to content

Add agent class#10

Open
bz247 wants to merge 23 commits intodevelopfrom
agent
Open

Add agent class#10
bz247 wants to merge 23 commits intodevelopfrom
agent

Conversation

@bz247
Copy link

@bz247 bz247 commented Mar 19, 2020

Create an agent class #7

Getting current edge not included yet.

@kks32 kks32 self-requested a review March 19, 2020 12:32
@kks32 kks32 self-assigned this Mar 19, 2020
Copy link
Contributor

@kks32 kks32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid explicitly saying get_ and set_ methods, use function overlaoding instead. Please revise the class as requested

include/agent.h Outdated
//! \param[in] agent_id Agent id assigned to the agent object
void set_id(graph::vertex_t agent_id) { this->agent_id_ = agent_id; }
//! Get id
graph::vertex_t get_id() const { return agent_id_; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use get and set methods, instead overload these functions just use id

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not understand... Do you mean I should define two functions both named id, one has inputs (to set the id) while the other does not (to get the id)?

include/agent.h Outdated
int get_status() const { return status_; }

//! Compute path based on current node and destination
void compute_agent_path();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest we assign path to agent, rather than compute it at agent level.

include/agent.h Outdated

//! Set origin and initialize current node to origin
//! \param[in] origin Origin vertex assigned to agent
void set_origin(graph::vertex_t origin) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the constructor, this is just a function.

Copy link
Contributor

@kks32 kks32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there a .clang-format file?

include/agent.h Outdated

//! Set origin and initialize current node to origin
//! \param[in] origin Origin vertex assigned to agent
void set_origin(graph::vertex_t origin) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can have one function to set origin and destinations

graph::vertex_t destination_{std::numeric_limits<graph::vertex_t>::max()};

//! Agent departure time
graph::weight_t departure_time_{std::numeric_limits<graph::weight_t>::max()};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a double

@codecov-io
Copy link

codecov-io commented Mar 19, 2020

Codecov Report

Merging #10 into develop will increase coverage by 0.19%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #10      +/-   ##
===========================================
+ Coverage    93.98%   94.17%   +0.19%     
===========================================
  Files           11       13       +2     
  Lines          548      566      +18     
===========================================
+ Hits           515      533      +18     
  Misses          33       33              
Impacted Files Coverage Δ
include/agent.h 100.00% <100.00%> (ø)
tests/agent_test.cc 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c0fa5a...b613103. Read the comment docs.

//! \param[in] id Agent id
//! \param[in] origin Agent origin
//! \param[in] destination Agent destination
explicit Agent(const graph::vertex_t& id) : id_{id} {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please only declare functions in the header, do not define them. Please define functions in the implementation .cc file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I see { return nvertices_; } in graph.h

include/agent.h Outdated
graph::vertex_t current_node() const { return current_node_; }

//! status: 0: haven't started routing. 1: en_route. 2: arrived.
enum class Status { PREDEPART, ENROUTE, ARRIVE };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be defined outside the Agent class.

Suggested change
enum class Status { PREDEPART, ENROUTE, ARRIVE };
enum class Status { YETTODEPART, ENROUTE, ARRIVED };

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Would they also be used by other classes?

@@ -0,0 +1,66 @@
// #include <vector>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these if you are not using these


//! Return agent status
//! \retval Status of the agent.
//! destination.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it say destination?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants