Skip to content

Kernel abstractions#253

Merged
AboudyKreidieh merged 8 commits intomasterfrom
kernel_abstract
Dec 17, 2018
Merged

Kernel abstractions#253
AboudyKreidieh merged 8 commits intomasterfrom
kernel_abstract

Conversation

@AboudyKreidieh
Copy link
Member

@AboudyKreidieh AboudyKreidieh commented Nov 18, 2018

This PR contains all abstractions to the kernel class, and is meant to give a sense of the overall architecture of what is to come. All methods current raise NotImplmenetedError, and the bulk of the changes are actually documentation. The person reading this is simply meant to read the docstrings and comment on the chose of design. In its current form, the kernel consists of four "sub-kernels" covering simulations, scenarios, traffic lights, and kernels. More details can be found within the PR itself.

@AboudyKreidieh AboudyKreidieh changed the title added abstractions to the kernel Kernel abstractions Nov 18, 2018
@coveralls
Copy link

coveralls commented Nov 18, 2018

Pull Request Test Coverage Report for Build 2061

  • 0 of 133 (0.0%) changed or added relevant lines in 5 files are covered.
  • 125 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-0.4%) to 84.133%

Changes Missing Coverage Covered Lines Changed/Added Lines %
flow/core/kernel/traffic_light/base.py 0 10 0.0%
flow/core/kernel/simulation/base.py 0 11 0.0%
flow/core/kernel/kernel.py 0 23 0.0%
flow/core/kernel/scenario/base.py 0 37 0.0%
flow/core/kernel/vehicle/base.py 0 52 0.0%
Files with Coverage Reduction New Missed Lines %
flow/controllers/routing_controllers.py 1 92.68%
tests/slow_tests/test_benchmarks.py 2 97.26%
flow/envs/green_wave_env.py 8 83.11%
flow/core/rewards.py 8 88.66%
flow/envs/multiagent_env.py 12 69.23%
flow/visualize/visualizer_rllib.py 31 78.62%
flow/envs/base_env.py 63 73.77%
Totals Coverage Status
Change from base Build 1678: -0.4%
Covered Lines: 6877
Relevant Lines: 8174

💛 - Coveralls

self.traffic_light.pass_api(kernel_api)

def update(self, reset):
"""Update the kernel subclasses with after a simulation step.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be: "Update the kernel subclasses after a simulation step"

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@AboudyKreidieh AboudyKreidieh mentioned this pull request Nov 27, 2018

>>> k = Kernel(simulator="...") # a kernel for some simulator type
>>> veh_id = "..." # some vehicle ID
>>> k.vehicle.apply_acceleration(veh_id)
Copy link
Member

Choose a reason for hiding this comment

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

apply_acceleration is moving to the vehicle class? Which class subclasses GymEnv?

Copy link
Member

Choose a reason for hiding this comment

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

Also, not sure if I agree with the variable name k for the kernel. While it's abundantly clear to us what it means, it may add additional confusion for new developers.

Copy link
Member Author

Choose a reason for hiding this comment

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

So the gym env will still be in base env, with all the relevant calls available from there. What this is meant to do is when you pass a command to the simulator, the command isn't sent to a method within the gym class, but rather to a method within the correct simulation kernel. That way apply_acceleration can work for any simulator without us having to modify the envs.

Copy link
Member Author

Choose a reason for hiding this comment

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

In terms of k, we'll have documentation on this, but if you'd rather we call it something else, e.g. self.kernel, I'd be down too. It just makes calling commands longer

format(simulator))

def pass_api(self, kernel_api):
"""Pass the kernel API to all kernel subclasses."""
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be called in the init? Otherwise where do they get access to this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Init actually is going to consist of three stages:

  • create the scenario files
  • start the simulation and generate the kernel api
  • pass the kernel api to the kernel and all kernel subclasses

"""
raise NotImplementedError

def prev_edge(self, edge, lane):
Copy link
Member

Choose a reason for hiding this comment

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

Since we're redoing this right now, we may want to discuss what the appropriate thing to do is when two edges converge at a single edge

Copy link
Member Author

Choose a reason for hiding this comment

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

sure! this is just architecturally what things will look like, but we can have this discussion when we start adding actual code

@@ -0,0 +1,85 @@
"""Script containing the base simulation kernel class."""

Copy link
Member

Choose a reason for hiding this comment

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

Repeat; does this become the gym Env?

@eugenevinitsky
Copy link
Member

Looks good but we should discuss the raised issues.

@eugenevinitsky
Copy link
Member

Okay, this looks fine to me. I'm approving it and you can merge it when you're ready.

@AboudyKreidieh
Copy link
Member Author

Sounds good! The issues will be thoroughly addressed when we get to the actual code. But the concerns are noted and I'll keep them in mind as we move forward.

@AboudyKreidieh AboudyKreidieh merged commit e89684e into master Dec 17, 2018
@AboudyKreidieh AboudyKreidieh deleted the kernel_abstract branch December 17, 2018 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants