ds4dm / ecole

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

the variables' order in the ecole.observation.NodeBipartite() #318

Open stardustwls opened 2 years ago

stardustwls commented 2 years ago

Describe the bug

when using ecole.observation.NodeBipartite(), we will get the variable features (19-dimensions) and the 13th is the incumbent. However, it seems that the order of the variable in the ecole.observation.NodeBipartite() is not coresponding to the .lp file, x1, x2, x3, x4, ... image for example, we display features of 17 variables, but they are not the x1-x17 in the .lp file. Could you please tell me the coresponding relationship between them? Thank you very much!

AntoinePrv commented 2 years ago

Hi @stardustwls,

SCIP will reorder the problem during transform (even during loading).

You can try overriding the environment's dynamics set_dynamics_random_state to deactivate the randomization/permutationseed parameters.

Alternatively, you can use Pyscipopt (env.model.as_pyscipopt()) to get the names of the variables and compare that with the one from your LP file.

LeonaireHo commented 2 years ago

Hi, I have tried by setting randomization/permutationseed to 0 but that didn't work, and the names of the vars I get from pyscipopt are always in ascending order, like "x0, x1, etc" .

To solve this problem, I modified the code in NodeBipartiteObs and added a feature to indicate the indice in the original problem. int i = SCIPvarGetProbindex(var); SCIP_VAR* aux = SCIPgetOrigVars(scip)[i]; out[idx(VariableFeatures::index)] = SCIPvarGetProbindex(SCIPvarGetTransVar(aux)); This is not a good solution, but it works. If anyone has any suggestions or better methods, please let me know. Thank you.