ds4dm / ecole

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

AttributeError: 'ecole.core.observation.NodeBipartiteObs' object has no attribute 'variable_features' #310

Closed ZhiweiShan closed 2 years ago

ZhiweiShan commented 2 years ago

Describe the bug

When I run the branching-imitation example, it was fine until:

observation = train_data[0].to(DEVICE)

logits = policy(
    observation.constraint_features,
    observation.edge_index,
    observation.edge_attr,
    observation.variable_features,
)
action_distribution = F.softmax(logits[observation.candidates], dim=-1)

print(action_distribution)

I got the error report:

AttributeError                            Traceback (most recent call last)
<ipython-input-13-4842d4bcbfd3> in <module>()
----> 1 observation = train_data[0].to(DEVICE)
      2 
      3 logits = policy(
      4     observation.constraint_features,
      5     observation.edge_index,

/home/dryi/anaconda3/envs/ecole2/lib/python3.6/site-packages/torch_geometric/data/dataset.py in __getitem__(self, idx)
    196                 or (isinstance(idx, np.ndarray) and np.isscalar(idx))):
    197 
--> 198             data = self.get(self.indices()[idx])
    199             data = data if self.transform is None else self.transform(data)
    200             return data

<ipython-input-10-c9da1c62e7ff> in get(self, index)
     66         edge_indices = sample_observation.edge_features.indices.astype(np.int32)
     67         edge_features = np.expand_dims(sample_observation.edge_features.values, axis=-1)
---> 68         variable_features = sample_observation.variable_features
     69 
     70         # We note on which variables we were allowed to branch, the scores as well as the choice

AttributeError: 'ecole.core.observation.NodeBipartiteObs' object has no attribute 'variable_features'

Setting

Thank you for any help!

AntoinePrv commented 2 years ago

Hi @ZhiweiShan ,

We recently released Ecole 0.8.0, so the branching tutorial you are running is probably using that new version. You can either update Ecole, or rollback to the v0.7.3 tag on Github.

ZhiweiShan commented 2 years ago

Hi Antoine,

Thank you very much. It helps.