Error code = 10004 Unable to retrieve attribute 'X' - I need some direction which way to look for to fix this

3,096 views
Skip to first unread message

Dorien Herremans

unread,
Oct 9, 2013, 6:38:34 AM10/9/13
to gur...@googlegroups.com
Dear gurobiers,

I have to calculate something with a code written by my collegue. I have been studying it and it makes sense. It works for certain input files, but for most of them, I get this error:

Error code = 10004
Unable to retrieve attribute 'X'

Very strange. I read about this and it would appear related to not reading the labels correctly? That is very strange, since it does work with some files and writes model.write correctly.

Do you have any ideas? It would be really appreciated.

The cpp file is attached.

I made a toy problem, and this is the model.write output:

Maximize
  15 student_has_projects4.1
Subject To
 R0: student_has_projects0.0 + student_has_projects1.0
   + student_has_projects2.0 + student_has_projects3.0
   + student_has_projects4.0 + student_has_projects5.0
   + student_has_projects6.0 + student_has_projects7.0 <= 4
 R1: student_has_projects1.0 + student_has_projects2.0 >= 1
 R2: student_has_projects2.0 + 2 student_has_projects5.0 <= 2
 R3: student_has_projects2.0 + 2 student_has_projects5.0 >= 1
 R4: student_has_projects0.0 + student_has_projects3.0
   + student_has_projects4.0 + student_has_projects6.0
   + student_has_projects7.0 >= 1
 R5: student_has_projects2.0 + student_has_projects5.0 <= 1
 R6: student_has_projects0.1 + student_has_projects1.1
   + student_has_projects2.1 + student_has_projects3.1
   + student_has_projects4.1 + student_has_projects5.1
   + student_has_projects6.1 + student_has_projects7.1 <= 4
 R7: student_has_projects1.1 + student_has_projects2.1 >= 1
 R8: student_has_projects2.1 + 2 student_has_projects5.1 <= 2
 R9: student_has_projects2.1 + 2 student_has_projects5.1 >= 1
 R10: student_has_projects0.1 + student_has_projects3.1
   + student_has_projects4.1 + student_has_projects6.1
   + student_has_projects7.1 >= 1
 R11: student_has_projects2.1 + student_has_projects5.1 <= 1
 R12: student_has_projects0.2 + student_has_projects1.2
   + student_has_projects2.2 + student_has_projects3.2
   + student_has_projects4.2 + student_has_projects5.2
   + student_has_projects6.2 + student_has_projects7.2 <= 4
 R13: student_has_projects1.2 + student_has_projects2.2 >= 1
 R14: student_has_projects2.2 + 2 student_has_projects5.2 <= 2
 R15: student_has_projects2.2 + 2 student_has_projects5.2 >= 1
 R16: student_has_projects0.2 + student_has_projects3.2
   + student_has_projects4.2 + student_has_projects6.2
   + student_has_projects7.2 >= 1
 R17: student_has_projects2.2 + student_has_projects5.2 <= 1
 R18: student_has_projects0.0 + student_has_projects0.1
   + student_has_projects0.2 = 1
 R19: student_has_projects1.0 + student_has_projects1.1
   + student_has_projects1.2 = 1
 R20: student_has_projects2.0 + student_has_projects2.1
   + student_has_projects2.2 = 1
 R21: student_has_projects3.0 + student_has_projects3.1
   + student_has_projects3.2 = 1
 R22: student_has_projects4.0 + student_has_projects4.1
   + student_has_projects4.2 = 1
 R23: student_has_projects5.0 + student_has_projects5.1
   + student_has_projects5.2 = 1
 R24: student_has_projects6.0 + student_has_projects6.1
   + student_has_projects6.2 = 1
 R25: student_has_projects7.0 + student_has_projects7.1
   + student_has_projects7.2 = 1
Bounds
Binaries
 student_has_projects0.0 student_has_projects0.1 student_has_projects0.2
 student_has_projects1.0 student_has_projects1.1 student_has_projects1.2
 student_has_projects2.0 student_has_projects2.1 student_has_projects2.2
 student_has_projects3.0 student_has_projects3.1 student_has_projects3.2
 student_has_projects4.0 student_has_projects4.1 student_has_projects4.2
 student_has_projects5.0 student_has_projects5.1 student_has_projects5.2
 student_has_projects6.0 student_has_projects6.1 student_has_projects6.2
 student_has_projects7.0 student_has_projects7.1 student_has_projects7.2
End


The code is attached.

Example imput file (funny thing is that it works with 8 = 7 and the last column removed (also attached).

8                   
2                       
20091027    0    2    0    0    0
20102464    0    1    0    0    0
20101913    1    1    0    0    0
20090558    0    2    0    0    0
20072522    0    2    0    15    0
20092293    1    3    0    0    0
20093608    0    2    0    0    0
20093609    0    2    0    0    0

main.cpp
t5.txt

Sonja Mars

unread,
Oct 9, 2013, 7:29:07 AM10/9/13
to gur...@googlegroups.com
Hi,

Your model is infeasible, this is why Gurobi is not able to get the solution values of the variables (that is the meaning of "Unable to retrieve attribute 'X'"). You can for example see this quickly when using gurobi_cl for solving the lp-file.

For fixing your problem you should always check the solution status after solving a model and before trying to access the solution values. A description of the different status codes can be found here:
http://www.gurobi.com/documentation/5.6/reference-manual/optimization_status_codes#sec:StatusCodes

-- Sonja

-----------------------------------------------------------------
Dr. Sonja Mars
Technical Account Manager
Gurobi Optimization
> --
>
> ---
> You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> <t5.txt><main.cpp>

Reply all
Reply to author
Forward
0 new messages