Can someone help me out here! As I'm pretty new here in this topics, I would love to get any suggestion from you guys.Thanksfrom mip import Model, xsum, minimize, BINARYc_var_i = [10,13]y_t_i = [[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]]d_t = [[1, 2, 3, 4, 6, 7], [1, 2, 5, 4, 5, 4]]k_i = [[1, 2, 3, 4, 6, 7], [1, 2, 5, 4, 5, 4]]del_t = .25I = range(len(y_t_i))print(I)J = range(len(c_var_i))print(J)# c_sum = [c * sum(y_t_i[i]) for i,c in enumerate(c_var_i)]# c_sum*********m = Model("Electricity Demand")y = [[m.add_var() for i in I]]print(y)m.objective = minimize(c * xsum(y_t_i[i]) for i,c in enumerate(c_var_i))
getting some error here:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-32-96edd6ed2f2b> in <module> 4 print(y) 5 ----> 6 m.objective = minimize(c * xsum(y_t_i[i]) for i,c in enumerate(c_var_i)) 7 ~/Library/Python/3.8/lib/python/site-packages/mip/model.py in minimize(objective) 1529 if isinstance(objective, mip.Var): 1530 objective = mip.LinExpr([objective], [1.0]) -> 1531 objective.sense = mip.MINIMIZE 1532 return objective 1533 AttributeError: 'generator' object has no attribute 'sense'
*********--m += xsum(y_t_i[i] * del_t for i in I) == [[(i * .25) for i in c] for c in d_t]m += [[i for i in c] for c in y_t_i] <= [[i for i in c] for c in k_i]m.optimize()selected = [i for i in I if y[i].x >= 0.99]print("selected items: {}".format(selected))
You received this message because you are subscribed to the Google Groups "Python-MIP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-mip+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-mip/52a7c386-e241-4af7-b08d-c4802cc8885cn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-mip/930728ce-4071-4d6a-9cb7-6cd17feaf323n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-mip/f5ca73fb-f29e-4734-8407-d26fda8737bdn%40googlegroups.com.