Skip to content

How to train on datasets containing general integers #367

@samwu-learn

Description

@samwu-learn

Describe the bug

Setting

  • OS: <!--- e.g. MacOS, LInux --->
  • Compiler: <!--- if applicable e.g. gcc, clang... with version --->
  • Python version:
  • Ecole version:

To Reproduce

episode_counter, sample_counter = 0, 0
Path("samples/").mkdir(exist_ok=True)

We will solve problems (run episodes) until we have saved enough samples

while sample_counter < DATA_MAX_SAMPLES:
episode_counter += 1

observation, action_set, _, done, _ = env.reset(next(instances))
while not done:
    (scores, scores_are_expert), node_observation = observation
    action = action_set[scores[action_set].argmax()]

    # Only save samples if they are coming from the expert (strong branching)
    if scores_are_expert and (sample_counter < DATA_MAX_SAMPLES):
        sample_counter += 1
        data = [node_observation, action, action_set, scores]
        filename = f"samples/sample_{sample_counter}.pkl"

        with gzip.open(filename, "wb") as f:
            pickle.dump(data, f)

    observation, action_set, _, done, _ = env.step(action)

print(f"Episode {episode_counter}, {sample_counter} samples collected so far")

In the above code(code in ecole
/example.ipynb) , if the input instance contains an integer, the done variable is always true, and a pkl file cannot be generated for this instance,

Expected behavior

Additional context

I would greatly appreciate it with your generous assistance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions