scipopt / PySCIPOpt

Python interface for the SCIP Optimization Suite
https://pyscipopt.readthedocs.io/en/latest/
MIT License
826 stars 255 forks source link

Row- and Col id in edge of BiparteRepresentation might not match order in features #915

Closed Engberg-Jacob closed 1 month ago

Engberg-Jacob commented 1 month ago

This might not be unexpected behaviour, but I thought I'd report it nonetheless. When using the getBipartiteGraphRepresentation in the coming release, the order of variables in col_features and constraints in row_features doesn't match the col_idx and row_idx numbers in edge.

To Reproduce I've included a small working example in a zip-folder. It'll create a text folder with the first entry in col_features, row_features, and edge. The col_features corresponds to y_1 and row_features corresponds to demand_1. However the first edge indicates that variable 0, in constraint 0, should have a coefficient of -73. However, y_1 only has that coefficient in 2 other constraints (namely capacity_1 and total_capacity).

Expected behavior That the edge indexes correspond to the order in col_features and row_features.

System

This might not be unexpected behaviour, or there might be intricacies in how the rows and columns are referenced which I might not get. code-and-instance.zip

Opt-Mucca commented 1 month ago

Thanks for including the example! That made it much easier to understand what's going on.

I think there has been a misunderstanding. I think the most helpful thing to do is to read the definition of the transformed problem, a column, and a row in the following documentation: https://pyscipopt.readthedocs.io/en/latest/tutorials/vartypes.html# https://pyscipopt.readthedocs.io/en/latest/tutorials/constypes.html#

What I believe the three points of confusion are:

After checking through your instance: edge_features[0] is holding information about the transformed variable corresponding to y_1 (because the name of the variable is t_y_1) and I'd probably bet it's for the row representation of the capacity_1 constraint.

Engberg-Jacob commented 1 month ago

Alright, perfect! I'd imagined that it was simply transformation, but I wanted to be sure that row_idx and col_idx matched order of columns in col_features and rows in row_features. Thank you!