Skip to content

Commit

Permalink
UPDATE: Fix typos, PEP8 python format, correct declaration of return …
Browse files Browse the repository at this point in the history
…type (#47)
  • Loading branch information
iammix authored Aug 27, 2022
1 parent dd41534 commit 5a4ce42
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 26 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ We want to make contributing to this project as easy and transparent as possible
- Proposing new features
- Becoming a maintainer

## We Develop with Github
We use github to host code, to track issues and feature requests, as well as accept pull requests.
## We Develop with GitHub
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.

## We Use [Github Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
## We Use [GitHub Flow](https://guides.github.com/introduction/flow/index.html), So All Code Changes Happen Through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:

1. Fork the repo and create your branch from `main`.
Expand All @@ -20,7 +20,7 @@ Pull requests are the best way to propose changes to the codebase (we use [Githu
5. Make sure your code lints.
6. Issue that pull request!

## Report bugs using Github's [issues](https://github.com/nrel/graph-env/issues)
## Report bugs using GitHub's [issues](https://github.com/nrel/graph-env/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/NREL/graph-env/issues/new).

## License
Expand Down
74 changes: 61 additions & 13 deletions experiments/tsp/tsp_profiling.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"cell_type": "code",
"execution_count": 1,
"id": "491b3ee4",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -30,7 +34,11 @@
"cell_type": "code",
"execution_count": 2,
"id": "93a397e6",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"from graphenv.examples.tsp.graph_utils import make_complete_planar_graph\n",
Expand All @@ -46,7 +54,11 @@
"cell_type": "code",
"execution_count": 3,
"id": "94e1fdae",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"G_fn = lambda : make_complete_planar_graph(N=40)\n",
Expand All @@ -59,7 +71,11 @@
"cell_type": "code",
"execution_count": 4,
"id": "ee3fdbca",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -78,7 +94,11 @@
"cell_type": "code",
"execution_count": 5,
"id": "b46c6cee",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -97,7 +117,11 @@
"cell_type": "code",
"execution_count": 6,
"id": "7fb538bb",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"tsp_genv = GraphEnv({'state': tsp_state, 'max_num_children': 40})\n",
Expand All @@ -108,7 +132,11 @@
"cell_type": "code",
"execution_count": 7,
"id": "ac8f3a04",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -130,7 +158,11 @@
"cell_type": "code",
"execution_count": 8,
"id": "f5732a03",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -152,7 +184,11 @@
"cell_type": "code",
"execution_count": 9,
"id": "587089c0",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"input_obs = tsp_genv.make_observation()\n",
Expand All @@ -163,7 +199,11 @@
"cell_type": "code",
"execution_count": 10,
"id": "3db24ead",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"tsp_model = TSPModel._create_base_model(hidden_dim=256, embed_dim=256, num_nodes=40)\n",
Expand All @@ -174,7 +214,11 @@
"cell_type": "code",
"execution_count": 11,
"id": "c1ca31da",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand All @@ -195,7 +239,11 @@
"cell_type": "code",
"execution_count": 12,
"id": "112041ff",
"metadata": {},
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -234,4 +282,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
2 changes: 1 addition & 1 deletion graphenv/graph_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _stack_batch_dim(

def _mask_and_split_values(
flat_values: TensorType, obs: RepeatedValues, tensorlib: str = "tf"
) -> Tuple[TensorType]:
) -> Tuple[TensorType, TensorType]:
"""Returns the value for the current vertex (index 0 of values),
and the masked values of the action vertices.
Args:
Expand Down
4 changes: 2 additions & 2 deletions graphenv/vertex.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _make_observation(self) -> any:
def children(self) -> List[V]:
"""
Gets the child vertices of this vertex.
Acts as a wrapper that memoizes calls to _get_children() and
Acts as a wrapper that memorizes calls to _get_children() and
ensures that it is a list. If you would like a different behavior,
such as stochastic child vertices, override this property.
Expand All @@ -93,7 +93,7 @@ def children(self) -> List[V]:
def observation(self) -> any:
"""
Gets the observation of this vertex.
Acts as a wrapper that memoizes calls to _make_observation().
Acts as a wrapper that memorizes calls to _make_observation().
If you would like a different behavior,
such as stochastic observations, override this property.
Expand Down
2 changes: 1 addition & 1 deletion joss/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ molecular optimization, for example, one can use domain knowledge alongside exis
libraries to model the effect of adding a single bond or atom to an existing but incomplete
molecule, and let the RL algorithm build a model of how good a given decision is by "experiencing"
the simulated environment many times through. In contrast, a model-based mathematical
formulation that fully expresses all of the chemical and physical constraints is intractable.
formulation that fully expresses all the chemical and physical constraints is intractable.

In recent years, RL has emerged as an effective paradigm for optimizing searches over graphs
and led to state-of-the-art heuristics for games like Go and chess, as well as for classical CO
Expand Down
2 changes: 1 addition & 1 deletion tests/test_graph_model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ def test_mask_and_split_values(obs, vals, tensorlib, request):
dtype_min = torch.finfo(action_vals.dtype).min

for length, val_row in zip([1, 4, 8, 2, 4], action_vals.numpy()):
assert np.allclose(val_row[length - 1 :], dtype_min)
assert np.allclose(val_row[length - 1:], dtype_min)
2 changes: 0 additions & 2 deletions tests/test_hallway.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def test_graphenv_step(hallway_env: GraphEnv):


def test_rllib(ray_init, agent, caplog):

trainer_fn, config, needs_q_model = agent
model = HallwayQModel if needs_q_model else HallwayModel

Expand Down Expand Up @@ -103,7 +102,6 @@ def test_rllib(ray_init, agent, caplog):


def test_rllib_torch(ray_init, agent, caplog):

trainer_fn, config, needs_q_model = agent
if needs_q_model:
pytest.skip("DQN in torch not currently working")
Expand Down
2 changes: 0 additions & 2 deletions tests/test_tsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def G(N):


def test_graphenv():

env = GraphEnv(
{
"state": TSPState(
Expand All @@ -33,7 +32,6 @@ def test_graphenv():


def test_rllib_base(ray_init, agent, N, G):

trainer_fn, config, needs_q_model = agent
model = TSPQModel if needs_q_model else TSPModel

Expand Down

0 comments on commit 5a4ce42

Please sign in to comment.