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

R Gurobi - how to add quadratic constraint with linear terms into the model?

回答済み

コメント

3件のコメント

  • 正式なコメント
    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?.
  • Eli Towle
    • Gurobi Staff

    You can add linear terms to quadratic constraints by specifying the \( \texttt{q} \) component (see the R documentation). E.g., if you have two variables \( x \) and \( y \), you can add the constraint \( x^2 + y^2 + xy + y \leq 3 \) with:

    qc1 <- list()
    qc1$Qc <- matrix(c(1,1,0,1), nrow=2)
    qc1$rhs <- 3
    qc1$q <- c(0,1)
    model$quadcon <- list(qc1)
    0
  • Yuqi Su
    • Gurobi-versary
    • First Question
    • First Comment

    Got it, thank you Eli!

    0

投稿コメントは受け付けていません。