Skip to main content

how to write code in GURBI MATLAB API for the constraint which is having expression in the right hand side .




  • Ahmed Azab
    Gurobi Staff Gurobi Staff

    Hi AMIT,

    Please refer to the Gurobi reference manual for a better understanding of using Gurobi with MATLAB.

    Here, you will find MATLAB API Overview.
    Here, you will find more MATLAB Examples.

    - Ahmed


    First Comment
    First Question

    Hello Ahmed Azab,

    Thanks a lot,

    I have gone through the Gurobi reference manual, from the reference manual I am not clear that how to model the constraint if it is having expression in RHS. As per the reference manual, GUROBI-MATLAB API requires constant term in the RHS. The below quoted line is written in the Gurobi reference manual.

    ''Note that the matrix oriented Gurobi APIs (C, MATLAB, and R) require the right-hand side of a linear constraint to be a constant, while the object-oriented APIs (C++, Java, .NET, and Python) allow arbitrary linear expressions on both sides of the comparator''.

    I am a beginner of GUROBI. kindly help me to write the below given equation in GUROBI MATLAB API.

    In the above given equation, i and j are different points, t denotes tine interval. QLji,t is the power flow from point j to i and QLij,t is the power flow from i to j. Qi,t is the power flow in any one direction. Qi,t is the total power at point i at time time t . 

    Looking forward for the solution



  • Ahmed Azab
    Gurobi Staff Gurobi Staff

    You can rearrange the equality so that all variables are on the LHS, and the RHS value is zero:

    X = Y - Z 

    to be 

    X - Y + Z = 0

    I am not familiar enough with the Matlab API to provide a specific implementation for your constraint.  But let's see if any of my colleagues, or someone from the community, can respond.

    - Ahmed


Please sign in to leave a comment.