ds4dm / ecole

Extensible Combinatorial Optimization Learning Environments
https://www.ecole.ai
BSD 3-Clause "New" or "Revised" License
325 stars 68 forks source link

Declaring multiple integral reward functions #205

Open jdumouchelle opened 3 years ago

jdumouchelle commented 3 years ago

Describe the bug

With the current reward function implementation we are unable to declare multiple reward function in a single environment.

Setting

To Reproduce

Declare an environment with at least two integral reward functions either in the reward_function or information_function and call reset on an instance.

import ecole 

env = ecole.environment.Configuring(
    observation_function=None,
    reward_function = ecole.reward.PrimalDualIntegral(),
    information_function={
        'dualintegral': ecole.reward.DualIntegral().cumsum(),
    }
)

instances = ecole.instance.SetCoverGenerator()
instance = next(instances)

env.reset(instance)

This will give the error:

Exception: [scip_event.c:76] ERROR: event handler <ecole::reward::IntegralEventHandler> already included.
[objeventhdlr.cpp:229] ERROR: Error <-9> in function call

Expected behavior

No exceptions.

Additional context

We need to decide on how we want to resolve the issue of multiple integral reward functions since they will create an event handler with the same name causing an exception in scip.