from gurobipy import *

a = 8638
b = 42

# Create (empty) model.
model = Model("Integer program for GCD")
model.modelSense = GRB.MINIMIZE

# Add variables.
x = model.addVar(name='x', vtype=GRB.INTEGER, lb=-GRB.INFINITY, obj=a)
y = model.addVar(name='y', vtype=GRB.INTEGER, lb=-GRB.INFINITY, obj=b)

# Always do this after adding variables.
model.update()

# Add constraints
model.addConstr( a * x + b * y >= 1)

# Always do this after adding constraints.
model.update()

# Solve the model.
model.optimize()

if model.status == GRB.OPTIMAL:
   print('Solved to optimality. gcg of %s and %s is %s.' % (a, b, model.objVal))
else:
   print('Could not solve to optimality.')
