5

я получаю ошибку в моем C++/gurobi файл:gurobi - Код ошибки = 10004 Невозможно получить атрибут 'X'

Код ошибки = 10004 Невозможно получить атрибут 'X'

Я прочитал, что это может иметь какое-то отношение к ярлыкам? Но я не вижу, как возникает проблема. Он работает для некоторых входных файлов, но не для других. Поэтому я создал файл игрушки, t5.txt в приложении. Этот файл не работает, но удаление последнего столбца и установка 8-7 исправляет его. Я озадачен ...

Ниже приведено изображение model.write. Кажется, все имеет смысл, какие-то идеи, что я делаю неправильно? Всякий раз, когда я делаю model.write (test.sol), программа останавливается, так что, кажется, что-то не так с раствором>

Вложения: main.cpp ->https://dl.dropboxusercontent.com/u/13564139/main.cpp

input.txt - >https://dl.dropboxusercontent.com/u/13564139/t5.txt

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 

ответ

6

проблема в том, что ваш экземпляр LP является недопустимым, поэтому вызов .optimize() результатов в недопустимом состоянии. С вашего кода

model.write("test2.lp"); 
model.optimize(); 
model.write("forum2.sol"); 

if(model.get(GRB_IntAttr_Status) != GRB_OPTIMAL){ 
    cout << "niet optimaal " << endl; 
} 

Вы пишете файл .sol, прежде чем проверять на успех. Gurobi получает атрибуты «X» из переменных при записи файла .sol. Если оптимизация завершилась неудачей, атрибуты «Х» недоступны и генерируется исключение. Вы должны убедиться, что у gurobi есть решение, прежде чем писать файл .sol или получить много атрибутов, включая «X», «Pi» и «ObjVal». OPTIMAL status codes гарантирует, что имеется доступное решение, но такие коды, как SUBOPTIMAL, также показывают, что есть доступное решение, а другие, такие как TIME_LIMIT, NODE_LIMIT, означают, что может быть доступно решение. Вы можете получить атрибут SolCount, чтобы получить окончательное указание на доступность решения.

Ваш вопрос невозможен, поскольку ограничения (R1, R7, R13 подразумевают, что для учащихся 1 и 2 требуется как минимум 3 проекта, но ограничения (R19, R20) подразумевают, что они могут иметь ровно по 1 проект. с помощью решателя IIS. в интерактивном gurobi вы можете получить получаете Irreducible Inconsistent Subsystem

m = read("test2.lp") 
m.optimize() 
m.computeIIS() 
m.write("test2.ilp") 
+0

Я был только о записи, которую я нашел, что они где неосуществимым. Добавлены некоторые исправления (например, фиктивные экземпляры), чтобы сделать это возможным. Не действительно ясное сообщение об ошибке. – dorien

 Смежные вопросы

  • Нет связанных вопросов^_^