Skip to main content

Frank-Wolfe Problem.

Answered

Comments

5 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?.
  • Eli Towle
    • Gurobi Staff

    The matrix1.py and matrix2.py examples demonstrate how the matrix-oriented Python API can be used. Details about the matrix API can be found in the documentation for MVarMLinExpr, and MQuadExpr objects. Note that variables should be MVar objects (i.e., added with Model.addMVar()) in order to use the matrix syntax.

    In your case, we can introduce auxiliary variables \( y \in \mathbb{R}^m \), set \( y \) equal to \( A x - b \), then minimize \( || y ||_2^2 = y^\top y\):

    import gurobipy as gp
    import numpy as np

    A = np.array([[1, 2, 3], [4, 5, 6]])
    b = np.array([7, 8])

    m = gp.Model()

    x = m.addMVar(3, name='x')
    y = m.addMVar(2, name='y')

    m.addConstr(A @ x - b == y)
    m.setObjective(y @ y)
    0
  • Cris
    • Gurobi-versary
    • Curious
    • Conversationalist

    Thanks you Eli. I could do the code. I have some questions. I had some troubles multiplying gurobi vars with an array. I would like to know if it is normal. I have read this. https://groups.google.com/g/gurobi/c/wmEzO3cQLdM. 

    Also, in my code y had a loop. I would like to know if I can set a gurobi parameter to don´t print the optimization information. I would like this because this information don´t let me see the evolution of the data in each iteration.

    Best regards and thanks for your answer 

    Cristian. 

    0
  • Eli Towle
    • Gurobi Staff

    Can you post a minimal, self-contained code example that reproduces the error you are encountering?

    To disable solver output, you can set the OutputFlag parameter to 0:

    m.params.OutputFlag = 0

    I also recommend reading this article, which discusses how to suppress informational license output like

    Using license file /home/gurobiuser/gurobi.lic
    Academic license - for non-commercial use only
    0
  • Cris
    • Gurobi-versary
    • Curious
    • Conversationalist

    Thanks you Eli. 

    Best regard.

    Atte: Cristian

    0

Post is closed for comments.