Frank-Wolfe Problem.
AnsweredHello. I am trying to solve the following problem. 
I don't know how to make the Ax term with the gurobi sintax. I don´t know how to convert my vars to a column vector and make the dot product between A and x. I would like to know where I could read about this or find some information. Best regards.
I am trying something like this

-
Official comment
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?. -
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 MVar, MLinExpr, 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 -
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 -
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 only0 -
Thanks you Eli.
Best regard.
Atte: Cristian
0
Post is closed for comments.
Comments
5 comments