Hi,
The following implementation of the objective function seems to work. I tested it with random data for v_model, v_ref and v_wgtmat, but unfortunately it runs really slowly (hardly faster than brute-force).
m.setObjective(quicksum((v_ref - (sum([v_model[i,:] * x[i] for i in range(N)]) * (1./K)))**2 * v_wgtmat ) / sum(v_wgtmat), GRB.MINIMIZE)
Does anyone have any suggestions how to speed it up?
According to this site: "Note that while quicksum is much faster than sum, it isn't the fastest approach for building a large expression. Use addTerms or the LinExpr() constructor if you want the quickest possible expression construction." How can that be applied to the line above?