result not correct
Answeredfrom gurobipy import *
import pandas as pd
import numpy as np
n=5 #number of noeds
k=3 #number of color
Arcs=[
(1,2),
(1,5),
(2,1),
(2,3),
(2,4),
(3,2),
(3,4),
(4,2),
(4,3),
(4,5),
(5,1),
(5,4),
]
N = [i for i in range(1, n+1)]
K = [k for k in range(1,k+1)]
#create model
m=Model('Graph Coloring')
#create variables
x=m.addVars(N,K,vtype=GRB.BINARY,name='x')
y=m.addVars(K,vtype=GRB.BINARY,name='y')
#create constraints
m.addConstrs(x.sum(i,'k')==1 for i in N)
m.addConstrs(x[i,k]+x[j,k]<=y[k] for i,j in Arcs for k in K)
# objective function
m.modelSense = GRB.MINIMIZE
m.setObjective(quicksum(y[k] for k in K))
m.optimize()
Model is infeasible
Best objective -, best bound -, gap -
0
-
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
For infeasible model, please refer to How do I determine why my model is infeasible?
The term \(\texttt{x.sum(i,'k')}\) should read \(\texttt{x.sum(i,'*')}\).
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments