Skip to main content

How do i create two-dimensional array variable using addvars() in C++

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?.
  • Jaromił Najman
    • Gurobi Staff

    Hi,

    The C++ addVars function does not create a multidimensional array but a one dimensional array. In order to construct a 2 dimensional array of GRBVar objects, you can use

    GRBVar* v[47];
    for (int i = 0; i<47; i++)
    {
    v[i] = model.addVars(96);
    }

    You can then access the variables via \(\texttt{v[i][j]}\).

    Best regards,
    Jaromił

     

    1
  • Hongdong Xiong
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks it help me a lot!

    0

Post is closed for comments.