Source code for the experiment with column scalings

import sys
import random
import argparse
from gurobipy import *

# Use parameters for greater flexibility
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-f','--infile', help='Problem File',
                    default=None, required=True)
parser.add_argument('-s','--scale', help='Scaling Factor',
                    type=float, default=10000.0)
parser.add_argument('-w','--outfile', help='Save scaled model',
parser.add_argument('-o','--optimize', help='Optimize scaled problem',
                    type=int, default=1)
args = parser.parse_args()

# Load input problem
m = read(args.infile)
# Scale domain of all columns randomly in the given domain
for var in m.getVars():
  if var.vtype == GRB.CONTINUOUS:
    scale = random.uniform(args.scale/2.0, args.scale*2.0)
    flip = random.randint(0,3)
    if flip == 0:
      scale = 1.0
    elif flip == 1:
      scale = 1.0/scale
    col = m.getCol(var)
    for i in range(col.size()):
      coeff = col.getCoeff(i)
      row   = col.getConstr(i)
      m.chgCoeff(row, var, coeff*scale)
    var.obj = var.obj*scale
    if > -GRB.INFINITY:  =
    if var.ub < GRB.INFINITY:
      var.ub  = var.ub/scale

if args.outfile != None:

# Optimize
if args.optimize:
  if m.Status == GRB.OPTIMAL:
    print('Kappa: %e\n' % m.KappaExact)