Skip to main content

Conditional addGenConstrLogA for pH calculation

Awaiting user input

Comments

1 comment

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Tim,

    You could introduce 5 auxiliary binary variables \(b_i\) and a constraint stating that exactly \(1\) of these binaries is \(>0\).

    \[\begin{align*}
    \sum_i b_i &= 1\\
    b_i &\in \{0,1\}
    \end{align*}\]

    You can then use these binary variables in indicator constraints to model

    \[\begin{align*}
    b_i = 1 &\rightarrow y_i = \log(x)\\
    b_i = 0 &\rightarrow y_i = 0
    \end{align*}\]

    You can then get the final value by adding all \(y_i\) variables.

    In your constraints, you always use the same argument variable

    model.getVarByName("pH_negative")

    This makes 4 out of the 5 constraints redundant. Is this a typo or is some piece of information missing?

    Best regards, 
    Jaromił

    0

Please sign in to leave a comment.