Now with the CPLEX Matrix API you can do the same kind of changes of course.
Let me start with the example from
https://medium.com/@alexfleischer_84755/optimization-simply-do-more-with-less-zoo-buses-and-kids-part2-python-java-c-cc04558e49b5
And suppose that in buses 40 seats, suddenly we allow 70 kids.
# Import packages.
import cplex
my_prob = cplex.Cplex()
my_obj = [500, 400]
my_ub = [cplex.infinity, cplex.infinity]
my_lb = [0.0, 0.0]
my_ctype = "II"
my_colnames = ["nbBus40", "nbBus30"]
my_rhs = [300]
my_rownames = ["nbKids"]
my_sense = "G"
my_prob.objective.set_sense(my_prob.objective.sense.minimize)
my_prob.variables.add(obj=my_obj, lb=my_lb, ub=my_ub, types=my_ctype,
names=my_colnames)
rows = [[["nbBus40", "nbBus30"], [40,30]]]
my_prob.linear_constraints.add(lin_expr=rows, senses=my_sense,
rhs=my_rhs, names=my_rownames)
my_prob.solve()
print("cost = ", my_prob.solution.get_objective_value())
numcols = my_prob.variables.get_num()
sol = my_prob.solution.get_values()
for j in range(numcols):
print(my_colnames[j]," = ", sol[j])
#now let us do some change
print("now the 40 seats buses can bring 70 kids to the zoo")
my_prob.linear_constraints.set_coefficients(0,0,70)
my_prob.solve()
print("cost = ", my_prob.solution.get_objective_value())
numcols = my_prob.variables.get_num()
sol = my_prob.solution.get_values()
for j in range(numcols):
print(my_colnames[j]," = ", sol[j])
works fine and gives
cost = 3800.0
nbBus40 = 6.0
nbBus30 = 2.0
now the 40 seats buses can bring 70 kids to the zoo
MIP start 'm1' defined initial solution with objective 3800.0000.
cost = 2400.0
nbBus40 = 4.0
nbBus30 = 1.0