Skip to main content

Output information from a GRBColumn object to a text file

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Bo Yang
    • Gurobi-versary
    • Conversationalist
    • Curious

    Being more specific, I just want to output the GRBColumn to a text file and then reconstruct the column object by using the data from the txt. 

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Bo,

    First, you will need the size() of the column. With the known size, you can obtain all coefficient - constraint pairs via getCoeff() and getConstr(). For the constraint you will need some more info to retrieve it after reading from file, e.g., via the constraint name. You can get the corresponding constraint name via the get() function and use getConstrByName() later to get the particular constraint after reading the file. You now have all information to write the file. You could write it line by line as

    coefficient constraintName

    You can learn how to read and write a file in C++ at, e.g., W3Schools.

    After reading the file, you can reconstruct the column with the use of addTerm() to add the coefficient - constraint pairs one by one or addTerms() to add them all at once.

    Best regards,
    Jaromił

    0

Post is closed for comments.