It is possible to pointwise multiply an array and an MVar object:
$$\begin{align} \begin{bmatrix} a_1 \\ a_2 \\ a_3 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix}= \begin{bmatrix} a_1 x_1 \\ a_2 x_2 \\ a_3 x_3 \end{bmatrix}. \end{align}$$
This works natively, using numpy conventions:
import gurobipy as gp
import numpy as np
m = gp.Model()
x = m.addMVar(3)
a = np.array([1.0, 2.0, 3.0])
expr = a * x
Further information
- How do I pointwise multiply two MVars with the matrix-friendly Python API?
- How do I multiply two MLinExpr objects together with the matrix-friendly Python API?
- How do I multiply an array and a 2-D MVar object using the matrix-friendly Python API?
- How do I pointwise multiply a numpy vector with a (1,) MVar with the matrix-friendly Python API?