# Author : Manfred Scheucher # Date : Jul 23 2015 # Description: This python script generates an LP which can be solved by an # LP-solver. The following command gives an example how to # use this script with GLPK: # python b.py 5 > 5.lp && glpsol --lp 5.lp from sys import argv from itertools import combinations assert(1^1==0) # use python, not sage def b(x): return (n*'0'+bin(x)[2:])[-n:] # binary rep. with leading zeroes def v(x,y): assert(0<=x and x= 1" i+=1 for x in range(n): for y in range(n-2): print " c"+str(i)+":"+'+'.join(v(x,y+d) for d in range(3))+">= 1" i+=1 for x in range(n-2): for y in range(n-2): print " c"+str(i)+":"+'+'.join(v(x+d,y+d) for d in range(3))+">= 1" i+=1 for x in range(n-2): for y in range(2,n): print " c"+str(i)+":"+'+'.join(v(x+d,y-d) for d in range(3))+">= 1" i+=1 print "Binary" for x in range(n): for y in range(n): print v(x,y) print "End"