メインコンテンツへスキップ

Setting lower and upper bounds on multiple variables in a single API call

回答済み

コメント

1件のコメント

  • Dan Steffy
    • Gurobi Staff

    Thank you for the question. To set upper and lower bounds on indexed lists of variables in our C API, you can use GRBsetdblattrlist. Slightly modifying an example from that linked documentation, you could set upper bounds on variables 0, 1 and 3 as follows:

    int change[] = {0, 1, 3};
    double newub[] = {1.0, 3.0, 2.0};
    error = GRBsetdblattrlist(model, "UB", 3, change, newub);

    Note that you will have to make a separate call with appropriate input to set lower bounds. Some additional information about switching from CPLEX to Gurobi can be found on our Switching from CPLEX page. Another useful page is the C API Reference section of our reference manual.

    1

サインインしてコメントを残してください。