ds4dm / ecole

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

'ecole.core.observation.NodeBipartiteObs' object has no attribute 'variable_features' #364

Open nguyenminhtuong opened 1 year ago

nguyenminhtuong commented 1 year ago

Describe the bug

I run the example at https://github.com/ds4dm/ecole/blob/master/examples/branching-imitation/example.ipynb and encounter this error 'ecole.core.observation.NodeBipartiteObs' object has no attribute 'variable_features'

image

`--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[11], line 1 ----> 1 observation = train_data[0]

File ~/anaconda3/envs/mypython39/lib/python3.9/site-packages/torch_geometric/data/dataset.py:258, in Dataset.getitem(self, idx) 248 r"""In case :obj:idx is of type integer, will return the data object 249 at index :obj:idx (and transforms it in case :obj:transform is 250 present). 251 In case :obj:idx is a slicing object, e.g., :obj:[2:5], a list, a 252 tuple, or a :obj:torch.Tensor or :obj:np.ndarray of type long or 253 bool, will return a subset of the dataset at the specified indices.""" 254 if (isinstance(idx, (int, np.integer)) 255 or (isinstance(idx, Tensor) and idx.dim() == 0) 256 or (isinstance(idx, np.ndarray) and np.isscalar(idx))): --> 258 data = self.get(self.indices()[idx]) 259 data = data if self.transform is None else self.transform(data) 260 return data

Cell In[8], line 68, in GraphDataset.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 70 # We note on which variables we were allowed to branch, the scores as well as the choice 71 # taken by strong branching (relative to the candidates) 72 candidates = np.array(sample_action_set, dtype=np.int32)

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

Setting

To Reproduce

Just run the jupyter notebook at https://github.com/ds4dm/ecole/blob/master/examples/branching-imitation/example.ipynb

Expected behavior

Note that the expected result should be this image

nguyenminhtuong commented 1 year ago

I have been able to solve this problem. Somehow this command

image

Does not install ecole 0.8.1 or 0.8.0 but install 0.7.3 instead. This has lead me to change all variables that have the name variable_features to column_features

Now I am trying to install 0.8.1 but I am not really successful

TianXuan1zxh commented 8 months ago

Hello, can you tell me how you resolved this AttributeError? Just because of an issue with the ecole version?

Jackieziao commented 5 months ago

I think just replace the variable_features to colomn_features

Yige-Lei commented 3 months ago

I have also encountered this problem. It's because the version of ecole(like 0.7.3) is too old. You can first update your conda to the latest version(like 24.5.0) and then install 0.8.1ecole with conda install -c conda-forge ecoleor simply with conda install ecole. The latest version of conda can install 0.8.1ecole, but the old version of conda(like 23.7.4) can only install 0.7.3ecole. Hope this helps you!