After a while I figure out a way to fix my program step by step.
First run a MathProg program like this:
glpsol -m model.mod -d data.dat --output solution.txt --wglp glp.mod
Then run the broken C++ routine, and after gtl_simplex
run following commands:
glp_print_mip(problem, "broken_solution.txt");
glp_write_prob(problem, 0, "broken_glp.mod");
From solution.txt
and broken_solution.txt
I could figure out the difference between column and row constraints definition. It helps when we create mock first row equal to cost function, with free variable as a constrain. By rotating rows and column definitions we can make sure that both files will have thier respecitve rows and columns definitions in the same order.
Once those constraints are fixed we can start fixing actual data. glp.mod
and broken_glp.mod
will both contains definitions for each constraint as well as values for each row and column. They are 1-indexed, with 0-row being cost function factors.
If in C++ program we already have rows and column in the same order as in MathProg generated model we can easily compare both files - but first sort them e.g. like sort glp.mod > glp.sorted
- values for each row/column might occur in a different order even when we defined rows and columns in the same order as in MathProg file.
After a while I was able to fix my program to perform the same routine as MathProg one. The only difference was displayed accuracy, but that is only a matter of output formatting.