code stringlengths 1 1.49M | vector listlengths 0 7.38k | snippet listlengths 0 7.38k |
|---|---|---|
#
# Stochastic Optimization PS#1 Problem 6a
# Nurse Staffing
#
# Reference Format: Vehicle Routing Problem
#
# Imports
#
from coopr.pyomo import *
#from coopr.opt.base import solver
#
# Model
#
model = AbstractModel()
#
# Parameters
#
# Define sets
model.I = Set() # units
model.J = Set() # days
# Data_determinis... | [
[
1,
0,
0.125,
0.0114,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
14,
0,
0.1932,
0.0114,
0,
0.66,
0.0385,
722,
3,
0,
0,
0,
338,
10,
1
],
[
14,
0,
0.2727,
0.0114,
0,
... | [
"from coopr.pyomo import *",
"model = AbstractModel()",
"model.I = Set() # units",
"model.J = Set() # days",
"model.s = Param(model.I) # # of patients can be served each shift for each inital assignment",
"model.r = Param(model.I) # # of patients can be served after each reassignment",
"model.Cost = ... |
#
# Stochastic Optimization PS#1 Problem 6a
# Nurse Staffing
#
# Reference Format: Vehicle Routing Problem
#
# Imports
#
from coopr.pyomo import *
#from coopr.opt.base import solver
#
# Model
#
model = AbstractModel()
#
# Parameters
#
# Define sets
model.I = Set() # units
model.J = Set() # days
# Data_determinis... | [
[
1,
0,
0.1486,
0.0135,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
14,
0,
0.2297,
0.0135,
0,
0.66,
0.05,
722,
3,
0,
0,
0,
338,
10,
1
],
[
14,
0,
0.3243,
0.0135,
0,
... | [
"from coopr.pyomo import *",
"model = AbstractModel()",
"model.I = Set() # units",
"model.J = Set() # days",
"model.s = Param(model.I) # # of patients can be served each shift for each inital assignment",
"model.r = Param(model.I) # # of patients can be served after each reassignment",
"model.Cost = ... |
import cplex
import random
import numpy as np
from pylab import *
from stoch_trnsport_gen import *
from cplex.exceptions import CplexError
NI = 20
NJ = 20
NW = 20
prob,demand = gen_stoch_trnsport(NI, NJ, NW)
prob.solve()
I = range(NI)
J = range(NJ)
O = range(NW)
bigm = 0.1
print prob.solution.get_objective_value(),
... | [
[
1,
0,
0.0208,
0.0208,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.0417,
0.0208,
0,
0.66,
0.0385,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.0625,
0.0208,
0,
... | [
"import cplex",
"import random",
"import numpy as np",
"from pylab import *",
"from stoch_trnsport_gen import *",
"from cplex.exceptions import CplexError",
"NI = 20",
"NJ = 20",
"NW = 20",
"prob,demand = gen_stoch_trnsport(NI, NJ, NW)",
"prob.solve()",
"I = range(NI)",
"J = range(NJ)",
"O... |
import cplex
import random
import numpy as np
import time
from stoch_trnsport_gen import *
from cplex.exceptions import CplexError
import cplex.callbacks as CPX_CB
class MySolve(CPX_CB.SolveCallback):
def __call__(self):
self.times_called += 1
print "hello"
self.solve()
# print "Lowe... | [
[
1,
0,
0.0102,
0.0102,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.0204,
0.0102,
0,
0.66,
0.0385,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.0306,
0.0102,
0,
... | [
"import cplex",
"import random",
"import numpy as np",
"import time",
"from stoch_trnsport_gen import *",
"from cplex.exceptions import CplexError",
"import cplex.callbacks as CPX_CB",
"class MySolve(CPX_CB.SolveCallback):\n def __call__(self):\n self.times_called += 1\n print(\"hello... |
from coopr.pyomo import *
#
# Model
#
model = AbstractModel()
model.I = Set()
model.J = Set()
model.A = Param(model.J, model.I)
model.b = Param(model.J)
model.c = Param(model.I)
model.p = Param(model.J) #probability for scenarios
model.alpha = Param() #required chance
model.bigm = Param(model.J)
model.X = Var(... | [
[
1,
0,
0.0278,
0.0278,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
14,
0,
0.1667,
0.0278,
0,
0.66,
0.0588,
722,
3,
0,
0,
0,
338,
10,
1
],
[
14,
0,
0.2222,
0.0278,
0,
... | [
"from coopr.pyomo import *",
"model = AbstractModel()",
"model.I = Set()",
"model.J = Set()",
"model.A = Param(model.J, model.I)",
"model.b = Param(model.J)",
"model.c = Param(model.I)",
"model.p = Param(model.J) #probability for scenarios",
"model.alpha = Param() #required chance",
"model.bigm... |
import cplex
import random
import numpy as np
prob = cplex.Cplex()
prob.objective.set_sense(prob.objective.sense.minimize)
N = 5
M = 10
# Add continuous variables
bin_var_name = ["y" + str(i) for i in range(N)]
bin_var_type = ["B" for i in range(N)]
bin_var_obj = [random.randint(1,10) for i in range(N)]
con_var_nam... | [
[
1,
0,
0.0244,
0.0244,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.0488,
0.0244,
0,
0.66,
0.0556,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.0732,
0.0244,
0,
... | [
"import cplex",
"import random",
"import numpy as np",
"prob = cplex.Cplex()",
"prob.objective.set_sense(prob.objective.sense.minimize)",
"N = 5",
"M = 10",
"bin_var_name = [\"y\" + str(i) for i in range(N)]",
"bin_var_type = [\"B\" for i in range(N)]",
"bin_var_obj = [random.randint(1,10) for i ... |
import cplex
import random
import numpy as np
import time
from pylab import *
from stoch_trnsport_gen import *
from cplex.exceptions import CplexError
import mpl_toolkits.mplot3d.axes3d as p3
NI = 50
NJ = 50
NW = 500
I = range(NI)
J = range(NJ)
O = range(NW)
prob,demand = gen_stoch_trnsport(NI, NJ, NW, eps=0.2)
#prob... | [
[
1,
0,
0.011,
0.011,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.022,
0.011,
0,
0.66,
0.0345,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.033,
0.011,
0,
0.66,
... | [
"import cplex",
"import random",
"import numpy as np",
"import time",
"from pylab import *",
"from stoch_trnsport_gen import *",
"from cplex.exceptions import CplexError",
"import mpl_toolkits.mplot3d.axes3d as p3",
"NI = 50",
"NJ = 50",
"NW = 500",
"I = range(NI)",
"J = range(NJ)",
"O = r... |
import random
fname = 'chance_mod.dat'
f = open(fname, 'w')
random.seed(1000)
f.write('\n')
#f.write('hello, world' + '\n')
#f.write('second line')
def write_set(name, data, file):
f = file
size = len(data)
f.write('set' + ' ' + name + ' ' + ':='+' ')
for i in range(size):
f.write(data[i] + ' '... | [
[
1,
0,
0.0111,
0.0111,
0,
0.66,
0,
715,
0,
1,
0,
0,
715,
0,
0
],
[
14,
0,
0.0222,
0.0111,
0,
0.66,
0.0357,
190,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.0333,
0.0111,
0,
... | [
"import random",
"fname = 'chance_mod.dat'",
"f = open(fname, 'w')",
"random.seed(1000)",
"f.write('\\n')",
"def write_set(name, data, file):\n f = file\n size = len(data)\n f.write('set' + ' ' + name + ' ' + ':='+' ')\n for i in range(size):\n f.write(data[i] + ' ')\n f.write(';'+'\... |
import cplex
import random
import numpy as np
import time
from pylab import *
from stoch_trnsport_gen import *
from cplex.exceptions import CplexError
import mpl_toolkits.mplot3d.axes3d as p3
NI = 20
NJ = 20
NW = 20
I = range(NI)
J = range(NJ)
O = range(NW)
prob,demand = gen_stoch_trnsport(NI, NJ, NW, eps=0.5)
prob.s... | [
[
1,
0,
0.0102,
0.0102,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.0204,
0.0102,
0,
0.66,
0.0217,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.0306,
0.0102,
0,
... | [
"import cplex",
"import random",
"import numpy as np",
"import time",
"from pylab import *",
"from stoch_trnsport_gen import *",
"from cplex.exceptions import CplexError",
"import mpl_toolkits.mplot3d.axes3d as p3",
"NI = 20",
"NJ = 20",
"NW = 20",
"I = range(NI)",
"J = range(NJ)",
"O = ra... |
"""
This script is used for benchmarking the time takes for different formulations
includes
IP, SIP, IP(M*)
"""
from time import time
from ccfs.fscplex import fscplex
f = open("../output/bench_formulations.txt", 'w')
header = "%4s %4s" % ('NI', 'NS')
header += "%10s %10s %10s" % ("IP_v", "SIP_v", "IP(M*)_v")
header +... | [
[
8,
0,
0.038,
0.0633,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0759,
0.0127,
0,
0.66,
0.0769,
654,
0,
1,
0,
0,
654,
0,
0
],
[
1,
0,
0.0886,
0.0127,
0,
0.66,... | [
"\"\"\"\nThis script is used for benchmarking the time takes for different formulations\nincludes\nIP, SIP, IP(M*)\n\"\"\"",
"from time import time",
"from ccfs.fscplex import fscplex",
"f = open(\"../output/bench_formulations.txt\", 'w')",
"header = \"%4s %4s\" % ('NI', 'NS')",
"f.write(header)",
"ni_... |
"""
This script is used for benchmarking the time takes for different formulations
includes
IP, SIP, IP(M*)
"""
from time import time
from ccfs.fscplex import fscplex
f = open("../output/bench_formulations.txt", 'w')
header = "%4s %4s" % ('NI', 'NS')
header += "%10s %10s %10s" % ("IP_v", "SIP_v", "IP(M*)_v")
header +... | [
[
8,
0,
0.0411,
0.0685,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0822,
0.0137,
0,
0.66,
0.0769,
654,
0,
1,
0,
0,
654,
0,
0
],
[
1,
0,
0.0959,
0.0137,
0,
0.66... | [
"\"\"\"\nThis script is used for benchmarking the time takes for different formulations\nincludes\nIP, SIP, IP(M*)\n\"\"\"",
"from time import time",
"from ccfs.fscplex import fscplex",
"f = open(\"../output/bench_formulations.txt\", 'w')",
"header = \"%4s %4s\" % ('NI', 'NS')",
"f.write(header)",
"ni_... |
from ccfs.fscplex import fscplex
f = open("../output/bench_singlebigm.txt", 'w')
header = "%4s %4s" % ('NI', 'NS')
header += "%10s %10s %10s" % ("BigM", "Obj", "Nodes")
#header += "%10s %10s" % ('t_stre', 't_bigm')
header += "\n"
f.write(header)
NI = 20
NS = 20
fc = fscplex()
fc.generate_instance(NI, NS, eps=0.2)
f... | [
[
1,
0,
0.0323,
0.0323,
0,
0.66,
0,
780,
0,
1,
0,
0,
780,
0,
0
],
[
14,
0,
0.0968,
0.0323,
0,
0.66,
0.0909,
899,
3,
2,
0,
0,
693,
10,
1
],
[
14,
0,
0.129,
0.0323,
0,
... | [
"from ccfs.fscplex import fscplex",
"f = open(\"../output/bench_singlebigm.txt\", 'w')",
"header = \"%4s %4s\" % ('NI', 'NS')",
"f.write(header)",
"NI = 20",
"NS = 20",
"fc = fscplex()",
"fc.generate_instance(NI, NS, eps=0.2)",
"fc.parameters.read_file(\"../../param/stofac.prm\")",
"fc.write(\"fc... |
#################
# Created 5.5
# Used for benchmarking with range of two bigms
#################
from ccfs.fscplex import fscplex
fc = fscplex()
fc.generate_instance(NI = 2, NS=100, eps=0.2)
fc.parameters.read_file("../../param/stofac.prm")
fc.write("fc.lp")
for i in range(20):
val1 = i * 0.1
for j in range(... | [
[
1,
0,
0.3,
0.05,
0,
0.66,
0,
780,
0,
1,
0,
0,
780,
0,
0
],
[
14,
0,
0.4,
0.05,
0,
0.66,
0.2,
436,
3,
0,
0,
0,
968,
10,
1
],
[
8,
0,
0.45,
0.05,
0,
0.66,
0.4,
... | [
"from ccfs.fscplex import fscplex",
"fc = fscplex()",
"fc.generate_instance(NI = 2, NS=100, eps=0.2)",
"fc.parameters.read_file(\"../../param/stofac.prm\")",
"fc.write(\"fc.lp\")",
"for i in range(20):\n val1 = i * 0.1\n for j in range(20):\n val2 = j * 0.1\n fc.set_bigm_two(val1, val2... |
import time
import cplex
import cplex.callbacks as CPX_CB
import random
import numpy as np
from ccfs.instances import genfs
from ccfs.callbacks import CheckBounds
def bench_checkresolve(NI = 40, NS=35):
step = 0.1
flag = [0] #mutable
I = range(NI)
S = range(NS)
x_name = ["x" + '_' + str(i) for i in... | [
[
1,
0,
0.0152,
0.0152,
0,
0.66,
0,
654,
0,
1,
0,
0,
654,
0,
0
],
[
1,
0,
0.0303,
0.0152,
0,
0.66,
0.1111,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.0455,
0.0152,
0,
... | [
"import time",
"import cplex",
"import cplex.callbacks as CPX_CB",
"import random",
"import numpy as np",
"from ccfs.instances import genfs",
"from ccfs.callbacks import CheckBounds",
"def bench_checkresolve(NI = 40, NS=35):\n step = 0.1\n flag = [0] #mutable\n I = range(NI)\n S = range(NS... |
"""
This is the main benchmark script for the check and resolve procedure.
Created: May 7th
First version May 7th. Things begin to work as expected.
Todo:
Output result on instance from 10 to 100 with or without heuristics
Author: Derek Zhang
"""
import cplex
import random
import numpy as np
import sys
from time imp... | [
[
8,
0,
0.0444,
0.0806,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0968,
0.0081,
0,
0.66,
0.0556,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.1048,
0.0081,
0,
0.66... | [
"\"\"\"\nThis is the main benchmark script for the check and resolve procedure.\nCreated: May 7th\nFirst version May 7th. Things begin to work as expected.\n\nTodo:\nOutput result on instance from 10 to 100 with or without heuristics",
"import cplex",
"import random",
"import numpy as np",
"import sys",
"... |
"""
This script contains all callback functions that might be called during the procedure
Created: May 1st?
Version 1.0: May 7th
Author: Derek Zhang
Todo:
- Optimality condition improvement
- Code optimization and organization
"""
import cplex.callbacks as CPX_CB
class MySolve(CPX_CB.SolveCallback):
def __call_... | [
[
8,
0,
0.0247,
0.0453,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0535,
0.0041,
0,
0.66,
0.2,
959,
0,
1,
0,
0,
959,
0,
0
],
[
3,
0,
0.0761,
0.0329,
0,
0.66,
... | [
"\"\"\"\nThis script contains all callback functions that might be called during the procedure\n\nCreated: May 1st?\nVersion 1.0: May 7th\n\nAuthor: Derek Zhang\nTodo:",
"import cplex.callbacks as CPX_CB",
"class MySolve(CPX_CB.SolveCallback):\n def __call__(self):\n if self.get_num_nodes() < 1:\n ... |
"""
The main script that contains subclass of cplex class.
All customized featured are to be added incrementally
Created: May 1st?
Version 1.0 May 7th
Author Derek Zhang
"""
import cplex
import random
from math import floor
from heapq import nlargest
class fscplex(cplex.Cplex):
def __init__(self):
cplex... | [
[
8,
0,
0.0174,
0.0316,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
1,
0,
0.0348,
0.0032,
0,
0.66,
0.2,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.038,
0.0032,
0,
0.66,
... | [
"\"\"\"\nThe main script that contains subclass of cplex class.\nAll customized featured are to be added incrementally\n\nCreated: May 1st?\n\nVersion 1.0 May 7th",
"import cplex",
"import random",
"from math import floor",
"from heapq import nlargest",
"class fscplex(cplex.Cplex):\n def __init__(self)... |
import cplex
from time import time
from fs import fs
from callback import check_bigm_at_incumbent
from callback import check_bigm_at_branch
SZ = 40
f = open("results.txt","w")
c = fs()
c.parameters.read_file("../../param/stofac.prm")
c.gen_inst(NI = 2, NS = 50, RLB = 40, seed = 100)
c.solve()
f.write(str(c.solution.g... | [
[
1,
0,
0.0263,
0.0263,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.0526,
0.0263,
0,
0.66,
0.0588,
654,
0,
1,
0,
0,
654,
0,
0
],
[
1,
0,
0.0789,
0.0263,
0,
... | [
"import cplex",
"from time import time",
"from fs import fs",
"from callback import check_bigm_at_incumbent",
"from callback import check_bigm_at_branch",
"SZ = 40",
"f = open(\"results.txt\",\"w\")",
"c = fs()",
"c.parameters.read_file(\"../../param/stofac.prm\")",
"c.gen_inst(NI = 2, NS = 50, RL... |
from pylab import *
from time import time
from fs import fs
import numpy as np
import mpl_toolkits.mplot3d.axes3d as p3
NI = 2
NS = 40
RLB = 20
SZ = 30
c = fs()
c.parameters.read_file("../../param/stofac.prm")
c.gen_inst(NI = NI, NS = NS, RLB = RLB, seed = 100)
Z = np.zeros((SZ, SZ))
c.solve()
print c.solution.get_obj... | [
[
1,
0,
0.0238,
0.0238,
0,
0.66,
0,
735,
0,
1,
0,
0,
735,
0,
0
],
[
1,
0,
0.0476,
0.0238,
0,
0.66,
0.0323,
654,
0,
1,
0,
0,
654,
0,
0
],
[
1,
0,
0.0714,
0.0238,
0,
... | [
"from pylab import *",
"from time import time",
"from fs import fs",
"import numpy as np",
"import mpl_toolkits.mplot3d.axes3d as p3",
"NI = 2",
"NS = 40",
"RLB = 20",
"SZ = 30",
"c = fs()",
"c.parameters.read_file(\"../../param/stofac.prm\")",
"c.gen_inst(NI = NI, NS = NS, RLB = RLB, seed = 1... |
from time import time
from fs import fs
org_times = []
str_times = []
org_vals = []
str_vals = []
org_nodes = []
str_nodes = []
for i in range(10):
c = fs()
c.parameters.read_file("../../param/stofac.prm")
c.gen_inst(NI = 5, NS = 5, seed = i*20)
c.init_lists()
t0 = time()
c.solve()
t1 = ti... | [
[
1,
0,
0.027,
0.027,
0,
0.66,
0,
654,
0,
1,
0,
0,
654,
0,
0
],
[
1,
0,
0.0541,
0.027,
0,
0.66,
0.0588,
245,
0,
1,
0,
0,
245,
0,
0
],
[
14,
0,
0.1081,
0.027,
0,
0.6... | [
"from time import time",
"from fs import fs",
"org_times = []",
"str_times = []",
"org_vals = []",
"str_vals = []",
"org_nodes = []",
"str_nodes = []",
"for i in range(10):\n c = fs()\n c.parameters.read_file(\"../../param/stofac.prm\")\n c.gen_inst(NI = 5, NS = 5, seed = i*20)\n c.init_... |
import cplex
import random
class fs(cplex.Cplex):
def __init__(self):
cplex.Cplex.__init__(self) #has to be called to activa
self.NI = 1; self.NS = 1
self.I = range(self.NI); self.J = range(self.NS)
self.x_name = []; self.y_name = []; self.rhs = []
self.num_M = 0; self.M_row... | [
[
1,
0,
0.0093,
0.0093,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.0187,
0.0093,
0,
0.66,
0.5,
715,
0,
1,
0,
0,
715,
0,
0
],
[
3,
0,
0.5,
0.9346,
0,
0.66,
... | [
"import cplex",
"import random",
"class fs(cplex.Cplex):\n def __init__(self):\n cplex.Cplex.__init__(self) #has to be called to activa\n self.NI = 1; self.NS = 1\n self.I = range(self.NI); self.J = range(self.NS)\n self.x_name = []; self.y_name = []; self.rhs = []\n self.n... |
import cplex.callbacks as CPX_CB
class check_bigm_at_incumbent(CPX_CB.IncumbentCallback):
def __call__(self):
print "\n"
if self.fc.flag == 1:
#self.times_called += 1
x_val = self.get_values(self.fc.x_name)
y_val = self.get_values(self.fc.y_name)
slac... | [
[
1,
0,
0.0159,
0.0159,
0,
0.66,
0,
959,
0,
1,
0,
0,
959,
0,
0
],
[
3,
0,
0.2619,
0.4444,
0,
0.66,
0.5,
461,
0,
1,
0,
0,
175,
0,
10
],
[
2,
1,
0.2698,
0.4286,
1,
0.... | [
"import cplex.callbacks as CPX_CB",
"class check_bigm_at_incumbent(CPX_CB.IncumbentCallback):\n def __call__(self):\n print(\"\\n\")\n if self.fc.flag == 1:\n #self.times_called += 1\n x_val = self.get_values(self.fc.x_name)\n y_val = self.get_values(self.fc.y_nam... |
import cplex
import random
import numpy as np
#from instances import fscplex
from ccfs.fscplex import fscplex
from ccfs.callbacks import CheckBigM
from ccfs.callbacks import Reject
# Generate instances and read in parameters
fc = fscplex()
fc.generate_instance(NI = 15, NS=15, eps=0.2, Ordered=False)
fc.parameters.read_... | [
[
1,
0,
0.0159,
0.0159,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.0317,
0.0159,
0,
0.66,
0.04,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.0476,
0.0159,
0,
0.... | [
"import cplex",
"import random",
"import numpy as np",
"from ccfs.fscplex import fscplex",
"from ccfs.callbacks import CheckBigM",
"from ccfs.callbacks import Reject",
"fc = fscplex()",
"fc.generate_instance(NI = 15, NS=15, eps=0.2, Ordered=False)",
"fc.parameters.read_file(\"../param/stofac.prm\")"... |
import cplex
import random
import sys
from time import time
f1 = sys.argv[1]
f2 = sys.argv[2]
c = cplex.Cplex()
c.parameters.read_file("../../param/stofac.prm")
c.read(f1)
t0 = time()
c.solve()
t1 = time()
print "time is ", t1 - t0
print "solution is", c.solution.get_objective_value()
print "nodes is ", c.solution... | [
[
1,
0,
0.04,
0.04,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.08,
0.04,
0,
0.66,
0.0476,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.12,
0.04,
0,
0.66,
0.... | [
"import cplex",
"import random",
"import sys",
"from time import time",
"f1 = sys.argv[1]",
"f2 = sys.argv[2]",
"c = cplex.Cplex()",
"c.parameters.read_file(\"../../param/stofac.prm\")",
"c.read(f1)",
"t0 = time()",
"c.solve()",
"t1 = time()",
"print(\"time is \", t1 - t0)",
"print(\"solut... |
#This is a script that used on the command line to
# run .lp files
# The advantage is to be able to change the parameters
# directly from .lp file
import cplex
c=cplex.Cplex()
c.read("ccfs_new.lp")
c.parameters.read_file("../../param/stofac.prm")
c.solve()
print c.solution.get_objective_value()
print c.solution.get_... | [
[
1,
0,
0.3529,
0.0588,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
14,
0,
0.4706,
0.0588,
0,
0.66,
0.1111,
411,
3,
0,
0,
0,
890,
10,
1
],
[
8,
0,
0.5294,
0.0588,
0,
... | [
"import cplex",
"c=cplex.Cplex()",
"c.read(\"ccfs_new.lp\")",
"c.parameters.read_file(\"../../param/stofac.prm\")",
"c.solve()",
"print(c.solution.get_objective_value())",
"print(c.solution.get_values())",
"print(c.variables.get_names())",
"print(c.solution.get_linear_slacks())",
"print(c.solution... |
import cplex
import cplex.callbacks as CPX_CB
import random
import numpy as np
#from instances import fscplex
from fscplex import fscplex
from callbacks import CheckBounds
NI = 30
NS = 30
step = 0.1
# Generate instances and read in parameters
fc = fscplex()
fc.generate_instance(NI, NS)
fc.write("fc_org.lp")
fc.param... | [
[
1,
0,
0.0116,
0.0116,
0,
0.66,
0,
287,
0,
1,
0,
0,
287,
0,
0
],
[
1,
0,
0.0233,
0.0116,
0,
0.66,
0.0222,
959,
0,
1,
0,
0,
959,
0,
0
],
[
1,
0,
0.0349,
0.0116,
0,
... | [
"import cplex",
"import cplex.callbacks as CPX_CB",
"import random",
"import numpy as np",
"from fscplex import fscplex",
"from callbacks import CheckBounds",
"NI = 30",
"NS = 30",
"step = 0.1",
"fc = fscplex()",
"fc.generate_instance(NI, NS)",
"fc.write(\"fc_org.lp\")",
"fc.parameters.read_... |
# Farmer: rent out version has a singleton root node var
# note: this will minimize
#
# Imports
#
from coopr.pyomo import *
#
# Model
#
model = AbstractModel()
#
# Parameters
#
model.CROPS = Set()
model.TOTAL_ACREAGE = Param(within=PositiveReals)
model.PriceQuota = Param(model.CROPS, within=PositiveReals)
model... | [
[
1,
0,
0.0686,
0.0098,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
14,
0,
0.1275,
0.0098,
0,
0.66,
0.0323,
722,
3,
0,
0,
0,
338,
10,
1
],
[
14,
0,
0.1863,
0.0098,
0,
... | [
"from coopr.pyomo import *",
"model = AbstractModel()",
"model.CROPS = Set()",
"model.TOTAL_ACREAGE = Param(within=PositiveReals)",
"model.PriceQuota = Param(model.CROPS, within=PositiveReals)",
"model.SubQuotaSellingPrice = Param(model.CROPS, within=PositiveReals)",
"def super_quota_selling_price_valid... |
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
from ReferenceModel import model
import numpy
# Solve EV for given number of sample realizations with fixed X at X_EV
numSamples = 500
numX=5
optVal=numpy.array([0 for i in range(numSamples)])
# Choose the solver
opt = SolverFactory('gurobi')
# ... | [
[
1,
0,
0.0417,
0.0208,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
1,
0,
0.0625,
0.0208,
0,
0.66,
0.0588,
599,
0,
1,
0,
0,
599,
0,
0
],
[
1,
0,
0.0833,
0.0208,
0,
... | [
"from coopr.pyomo import *",
"from coopr.opt import SolverFactory",
"from ReferenceModel import model",
"import numpy",
"numSamples = 500",
"numX=5",
"optVal=numpy.array([0 for i in range(numSamples)])",
"opt = SolverFactory('gurobi')",
"EV_X = [9.2, 23.45, 5.1, 8.3, 4.95]",
"for i in range(numSam... |
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
from ReferenceModel import model
import numpy
# Solve WS for given number of sample realizations with fixed X at X_WS
numSamples = 500
numX = 5
optVal = numpy.array([0 for i in range(numSamples)])
# Choose the solver
opt = SolverFactory('gurobi')... | [
[
1,
0,
0.0435,
0.0217,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
1,
0,
0.0652,
0.0217,
0,
0.66,
0.0588,
599,
0,
1,
0,
0,
599,
0,
0
],
[
1,
0,
0.087,
0.0217,
0,
0... | [
"from coopr.pyomo import *",
"from coopr.opt import SolverFactory",
"from ReferenceModel import model",
"import numpy",
"numSamples = 500",
"numX = 5",
"optVal = numpy.array([0 for i in range(numSamples)])",
"opt = SolverFactory('gurobi')",
"WS_X = [9.2, 21.66, 5.00, 9.59, 5.49]",
"for i in range(... |
#This file estimate EV
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
import numpy
from ReferenceModelBase import model
# Solve WS for given number of sample realizations
numSamples=1
numX = 5
optVal = numpy.array ([0 for i in range(numSamples)])
optSoln = numpy.array([[0 for... | [
[
1,
0,
0.08,
0.02,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
1,
0,
0.1,
0.02,
0,
0.66,
0.0588,
599,
0,
1,
0,
0,
599,
0,
0
],
[
1,
0,
0.12,
0.02,
0,
0.66,
0.1... | [
"from coopr.pyomo import *",
"from coopr.opt import SolverFactory",
"import numpy",
"from ReferenceModelBase import model",
"numSamples=1",
"numX = 5",
"optVal = numpy.array ([0 for i in range(numSamples)])",
"optSoln = numpy.array([[0 for i in range(numSamples)] for j in range(numX)])",
"opt = Sol... |
#This file estimate EV
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
from ReferenceModel import model
import numpy
# Solve WS for given number of sample realizations
numSamples=20
numX = 5
optVal = numpy.array ([0 for i in range(numSamples)])
optSoln = numpy.array([[0 for i in range(numSam... | [
[
1,
0,
0.0612,
0.0204,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
1,
0,
0.0816,
0.0204,
0,
0.66,
0.05,
599,
0,
1,
0,
0,
599,
0,
0
],
[
1,
0,
0.102,
0.0204,
0,
0.6... | [
"from coopr.pyomo import *",
"from coopr.opt import SolverFactory",
"from ReferenceModel import model",
"import numpy",
"numSamples=20",
"numX = 5",
"optVal = numpy.array ([0 for i in range(numSamples)])",
"optSoln = numpy.array([[0 for i in range(numSamples)] for j in range(numX)])",
"opt = Solver... |
# Vehicle Routing Problem
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
# Model
model = AbstractModel()
# Sets
model.I = Set() #node
model.J = Set() #node
model.S = Set() #source node
model.D = Set() #demand node
# Data
model.Arc = Param(model.I, model.J) #arc available
m... | [
[
1,
0,
0.044,
0.011,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
1,
0,
0.0549,
0.011,
0,
0.66,
0.025,
599,
0,
1,
0,
0,
599,
0,
0
],
[
14,
0,
0.0879,
0.011,
0,
0.66... | [
"from coopr.pyomo import *",
"from coopr.opt import SolverFactory",
"model = AbstractModel()",
"model.I = Set() #node",
"model.J = Set() #node",
"model.S = Set() #source node",
"model.D = Set() #demand node",
"model.Arc = Param(model.I, model.J) #arc available",
"model.Rev = Param(model.I, model.J... |
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
import ReferenceModelBase
import numpy
"""
# Model
model = AbstractModel()
# Sets
model.I = Set() #node
model.J = Set() #node
model.S = Set() #source node
model.D = Set() #demand node
# Data
model.Arc = Param(model.I, model.J) ... | [
[
1,
0,
0.0179,
0.0089,
0,
0.66,
0,
594,
0,
1,
0,
0,
594,
0,
0
],
[
1,
0,
0.0268,
0.0089,
0,
0.66,
0.0556,
599,
0,
1,
0,
0,
599,
0,
0
],
[
1,
0,
0.0357,
0.0089,
0,
... | [
"from coopr.pyomo import *",
"from coopr.opt import SolverFactory",
"import ReferenceModelBase",
"import numpy",
"\"\"\"\n# Model\nmodel = AbstractModel()\n\n# Sets\nmodel.I = Set() #node\nmodel.J = Set() #node\nmodel.S = Set() #source node",
"numSamples=10",
"numX = 5",
"optVal = numpy.array ([0 for... |
#! /usr/bin/python
import glob
import shutil
import sys
import subprocess
import os
def cpfile(src, target):
sys.stdout.write("Copying %s to %s\n" % (src, target))
shutil.copy(src, target)
# We only copy the armeabi version of the binary
archs = ["armeabi"]
for arch in archs:
try:
os.makedirs(".... | [
[
1,
0,
0.0682,
0.0227,
0,
0.66,
0,
958,
0,
1,
0,
0,
958,
0,
0
],
[
1,
0,
0.0909,
0.0227,
0,
0.66,
0.1429,
614,
0,
1,
0,
0,
614,
0,
0
],
[
1,
0,
0.1136,
0.0227,
0,
... | [
"import glob",
"import shutil",
"import sys",
"import subprocess",
"import os",
"def cpfile(src, target):\n sys.stdout.write(\"Copying %s to %s\\n\" % (src, target))\n shutil.copy(src, target)",
" sys.stdout.write(\"Copying %s to %s\\n\" % (src, target))",
" shutil.copy(src, target)",
"a... |
#! /usr/bin/python
import glob
import shutil
import sys
import subprocess
import os
def cpfile(src, target):
sys.stdout.write("Copying %s to %s\n" % (src, target))
shutil.copy(src, target)
# We only copy the armeabi version of the binary
archs = ["armeabi"]
for arch in archs:
try:
os.makedirs(".... | [
[
1,
0,
0.0682,
0.0227,
0,
0.66,
0,
958,
0,
1,
0,
0,
958,
0,
0
],
[
1,
0,
0.0909,
0.0227,
0,
0.66,
0.1429,
614,
0,
1,
0,
0,
614,
0,
0
],
[
1,
0,
0.1136,
0.0227,
0,
... | [
"import glob",
"import shutil",
"import sys",
"import subprocess",
"import os",
"def cpfile(src, target):\n sys.stdout.write(\"Copying %s to %s\\n\" % (src, target))\n shutil.copy(src, target)",
" sys.stdout.write(\"Copying %s to %s\\n\" % (src, target))",
" shutil.copy(src, target)",
"a... |
#! /usr/bin/python
import glob
import shutil
import sys
import subprocess
import os
if 'linux' in sys.platform:
platform = 'linux'
else:
platform = 'darwin'
toolchain = "%s/android-toolchain" % os.getenv("HOME")
openssl_version = "1.0.0k"
encfs_version = "1.7.4"
def cpfile(src, target):
sys.stdout.write... | [
[
1,
0,
0.0405,
0.0135,
0,
0.66,
0,
958,
0,
1,
0,
0,
958,
0,
0
],
[
1,
0,
0.0541,
0.0135,
0,
0.66,
0.0526,
614,
0,
1,
0,
0,
614,
0,
0
],
[
1,
0,
0.0676,
0.0135,
0,
... | [
"import glob",
"import shutil",
"import sys",
"import subprocess",
"import os",
"if 'linux' in sys.platform:\n platform = 'linux'\nelse:\n platform = 'darwin'",
" platform = 'linux'",
" platform = 'darwin'",
"toolchain = \"%s/android-toolchain\" % os.getenv(\"HOME\")",
"openssl_version... |
#!/usr/bin/env python
#
# Copyright 2006, 2007 Google Inc. All Rights Reserved.
# Author: danderson@google.com (David Anderson)
#
# Script for uploading files to a Google Code project.
#
# This is intended to be both a useful script for people who want to
# streamline project uploads and a reference implementation for
... | [
[
8,
0,
0.1875,
0.0081,
0,
0.66,
0,
0,
1,
0,
0,
0,
0,
0,
0
],
[
14,
0,
0.1976,
0.004,
0,
0.66,
0.0833,
777,
1,
0,
0,
0,
0,
3,
0
],
[
1,
0,
0.2056,
0.004,
0,
0.66,
... | [
"\"\"\"Google Code file uploader script.\n\"\"\"",
"__author__ = 'danderson@google.com (David Anderson)'",
"import httplib",
"import os.path",
"import optparse",
"import getpass",
"import base64",
"import sys",
"def upload(file, project_name, user_name, password, summary, labels=None):\n \"\"\"Uplo... |
# -*- coding: utf-8 -*-
from ca import *
# Nombre: Claves Candidatas Creator/dor, aka clcncr)
# Funcion que toma un conjunto de cierres de atributos y es esquema universal
# y devuelve un NUEVO conjunto de claves candidatas.
# Requires:
# R = esquema universal (Set)
# LCA = List. de Cierre atributos (Set of tubples ... | [
[
1,
0,
0.0952,
0.0476,
0,
0.66,
0,
749,
0,
1,
0,
0,
749,
0,
0
],
[
2,
0,
0.8095,
0.4286,
0,
0.66,
1,
992,
0,
2,
1,
0,
0,
0,
2
],
[
14,
1,
0.6667,
0.0476,
1,
0,
... | [
"from ca import *",
"def getCCC(R, LCA):\n\tLCC = []\n\tfor cla in LCA:\n\t\t# verificamos si el cierre (ca[1]) es igual a R\n\t\tif cla.am <= R <= cla.am:\n\t\t\t#si son iguales => la agregamos al conjunto\n\t\t\t# agregamos una copia por las dudas...\n\t\t\tLCC.append(cla.a.copy())",
"\tLCC = []",
"\tfor cl... |
# -*- coding: utf-8 -*-
from df import *
from ca import *
def cierreAtributos (f, eu):
"""Usando el conjunto de d.f. y el esquema universal construimos el
cierre de atributos de cada atributo. Lo representaremos con un TAD
que es un par ordenado, donde la primer componente ('a') es el
atributo considerad... | [
[
1,
0,
0.0288,
0.0096,
0,
0.66,
0,
411,
0,
1,
0,
0,
411,
0,
0
],
[
1,
0,
0.0385,
0.0096,
0,
0.66,
0.1111,
749,
0,
1,
0,
0,
749,
0,
0
],
[
2,
0,
0.1923,
0.2788,
0,
... | [
"from df import *",
"from ca import *",
"def cierreAtributos (f, eu):\n\t\"\"\"Usando el conjunto de d.f. y el esquema universal construimos el\n\t cierre de atributos de cada atributo. Lo representaremos con un TAD\n\t que es un par ordenado, donde la primer componente ('a') es el\n\t atributo considerad... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# df.py
#
# Copyright 2009 Drasky Vanderhoff <drasky@drasky-laptop>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Softw... | [
[
1,
0,
0.3385,
0.0154,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
3,
0,
0.6769,
0.6308,
0,
0.66,
1,
411,
0,
8,
0,
0,
0,
0,
7
],
[
14,
1,
0.3846,
0.0154,
1,
0.58,
... | [
"from sys import *",
"class df:\n\talfa = set()\n\tbeta = set()\n\tdef __hash__(self):\n\t\treturn 0\n\tdef __repr__(self):\n\t\trep = \"(\"\n\t\tfor elem in self.alfa:",
"\talfa = set()",
"\tbeta = set()",
"\tdef __hash__(self):\n\t\treturn 0",
"\t\treturn 0",
"\tdef __repr__(self):\n\t\trep = \"(\"\n\... |
# -*- coding: utf-8 -*-
#
# FC.py
#
# Copyright 2009 Drasky Vanderhoff <drasky.vanderhoff@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation;... | [
[
1,
0,
0.1884,
0.0072,
0,
0.66,
0,
739,
0,
1,
0,
0,
739,
0,
0
],
[
1,
0,
0.1957,
0.0072,
0,
0.66,
0.1667,
411,
0,
1,
0,
0,
411,
0,
0
],
[
1,
0,
0.2029,
0.0072,
0,
... | [
"import copy",
"from df import *",
"from fprima import *",
"def union_partes_izq(d1,F):\n\t\n\t\"\"\" Fusiona todas las dependencias funcionales que tenga a alfa\n\t\tcomo parte izquierda de la misma \"\"\"\n\t\n\ttrash = []\n\tfor d2 in F:\n\t\tif d1.alfa == d2.alfa and not (d1 == d2):",
"\t\"\"\" Fusiona ... |
# -*- coding: utf-8 -*-
from attrs import *
from df import *
from clcncr import getCCC
from fprima import *
from c3fn import calculate3FN
from FNBC import calcular_FNBC, chequear_FNBC , chequear_FNBC_df
from FC import *
def mainProg():
# Para saber si ya se ha calculado la descomposición en FNBC
calcFNBC = False
... | [
[
1,
0,
0.0172,
0.0086,
0,
0.66,
0,
251,
0,
1,
0,
0,
251,
0,
0
],
[
1,
0,
0.0259,
0.0086,
0,
0.66,
0.125,
411,
0,
1,
0,
0,
411,
0,
0
],
[
1,
0,
0.0345,
0.0086,
0,
0... | [
"from attrs import *",
"from df import *",
"from clcncr import getCCC",
"from fprima import *",
"from c3fn import calculate3FN",
"from FNBC import calcular_FNBC, chequear_FNBC , chequear_FNBC_df",
"from FC import *",
"def mainProg():\n\t# Para saber si ya se ha calculado la descomposición en FNBC\n\tc... |
# -*- coding: utf-8 -*-
from df import *
import copy
#Vamos a hacer la parte primero del foreach
#Esta funcion va a chequear si algun Ri contiene a la dep. func. a->b
#LRi = Conjuntos de Ri (sets of sets)
#dep = Dependencia funcional a->b (es un tubple (a,b))
# Returns:
# True si encontramos
# False caso contrario
d... | [
[
1,
0,
0.0247,
0.0123,
0,
0.66,
0,
411,
0,
1,
0,
0,
411,
0,
0
],
[
1,
0,
0.037,
0.0123,
0,
0.66,
0.2,
739,
0,
1,
0,
0,
739,
0,
0
],
[
2,
0,
0.1914,
0.0988,
0,
0.66... | [
"from df import *",
"import copy",
"def isDepInRi(LRi, dep):\n\tcdep = dep.alfa | dep.beta # hacemos una union de a U b = {a,b}\n\t# ahora vamos a buscar si encontramos en alguno de los Ri cdep\n\tfor c in LRi:\n\t\tif cdep <= c:\n\t\t\t# si lo encontramos salimos\n\t\t\treturn True\n\treturn False",
"\tcdep ... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# df.py
#
# Copyright 2009 Drasky Vanderhoff <drasky@drasky-laptop>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Softw... | [
[
1,
0,
0.3385,
0.0154,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
3,
0,
0.6769,
0.6308,
0,
0.66,
1,
411,
0,
8,
0,
0,
0,
0,
7
],
[
14,
1,
0.3846,
0.0154,
1,
0.63,
... | [
"from sys import *",
"class df:\n\talfa = set()\n\tbeta = set()\n\tdef __hash__(self):\n\t\treturn 0\n\tdef __repr__(self):\n\t\trep = \"(\"\n\t\tfor elem in self.alfa:",
"\talfa = set()",
"\tbeta = set()",
"\tdef __hash__(self):\n\t\treturn 0",
"\t\treturn 0",
"\tdef __repr__(self):\n\t\trep = \"(\"\n\... |
# -*- coding: utf-8 -*-
from sys import *
class ca:
a = set()
am = set()
def __hash__(self):
return 0
def __repr__(self):
rep = "(ATRIBUTO/S: "
for elem in self.a:
rep += elem+' '
rep += ", CIERRE:"
for elem in self.am:
rep += ' '+elem
rep += ')'
return rep
def __str__(self):
rep = "(ATRIB... | [
[
1,
0,
0.0811,
0.027,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
3,
0,
0.5541,
0.8649,
0,
0.66,
1,
749,
0,
5,
0,
0,
0,
0,
8
],
[
14,
1,
0.1622,
0.027,
1,
0.17,
... | [
"from sys import *",
"class ca:\n\ta = set()\n\tam = set()\n\tdef __hash__(self):\n\t\treturn 0\n\tdef __repr__(self):\n\t\trep = \"(ATRIBUTO/S: \"\n\t\tfor elem in self.a:",
"\ta = set()",
"\tam = set()",
"\tdef __hash__(self):\n\t\treturn 0",
"\t\treturn 0",
"\tdef __repr__(self):\n\t\trep = \"(ATRI... |
# -*- coding: utf-8 -*-
from df import *
# Aca vamos a definir todos los atributos, y una funcion nos va a devolver un
# set, que vendria a ser el Esquema universal
# TODO
def getEsquemaUniversal():
return set(['Planilla.Numero', 'Planilla.Fecha', 'Encuestado.Edad', \
'Encuestado.Sexo', 'Encuestado.Ingreso_mensua... | [
[
1,
0,
0.0213,
0.0071,
0,
0.66,
0,
411,
0,
1,
0,
0,
411,
0,
0
],
[
2,
0,
0.2589,
0.383,
0,
0.66,
0.5,
467,
0,
0,
1,
0,
0,
0,
1
],
[
13,
1,
0.2624,
0.3759,
1,
0.88,... | [
"from df import *",
"def getEsquemaUniversal():\n\treturn set(['Planilla.Numero', 'Planilla.Fecha', 'Encuestado.Edad', \\\n\t'Encuestado.Sexo', 'Encuestado.Ingreso_mensual', \\\n\t'Encuestado.Profesion', 'Encuestado.Instruccion', \\\n\t'Encuestado.No_C.I.', 'Encuestado.Nombre_y_apellido', \\\n\t'Jefe_de_Grupo_Fam... |
# -*- coding: utf-8 -*-
from fprima import cierreAtributosAlfa
import copy
def calcular_FNBC (conjRi, Fpri, cierreAtr):
"""Descomposición en la forma normal de Boyce-Codd de un
conjunto de esquemas relacionales, para un F+ dado.
1º parámetro => conjunto de esquemas relacionales
2º parámetro => cierre de... | [
[
1,
0,
0.0236,
0.0079,
0,
0.66,
0,
540,
0,
1,
0,
0,
540,
0,
0
],
[
1,
0,
0.0315,
0.0079,
0,
0.66,
0.1429,
739,
0,
1,
0,
0,
739,
0,
0
],
[
2,
0,
0.1772,
0.2677,
0,
... | [
"from fprima import cierreAtributosAlfa",
"import copy",
"def calcular_FNBC (conjRi, Fpri, cierreAtr):\n\n\t\"\"\"Descomposición en la forma normal de Boyce-Codd de un\n\t conjunto de esquemas relacionales, para un F+ dado.\n\t 1º parámetro => conjunto de esquemas relacionales\n\t 2º parámetro => cierre d... |
# -*- coding: utf-8 *-*
import sys
import unittest
from tests.dijkstra import *
from tests.prim import *
from tests.kruskal import *
if __name__ == '__main__':
unittest.main()
| [
[
1,
0,
0.2,
0.1,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.3,
0.1,
0,
0.66,
0.2,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.5,
0.1,
0,
0.66,
0.4,
292,... | [
"import sys",
"import unittest",
"from tests.dijkstra import *",
"from tests.prim import *",
"from tests.kruskal import *",
"if __name__ == '__main__':\n unittest.main()",
" unittest.main()"
] |
# -*- coding: utf-8 *-*
import unittest
from tests_algorithms import *
from tests_graphs import *
from tests_structures import *
if __name__ == '__main__':
unittest.main()
| [
[
1,
0,
0.2222,
0.1111,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.4444,
0.1111,
0,
0.66,
0.25,
222,
0,
1,
0,
0,
222,
0,
0
],
[
1,
0,
0.5556,
0.1111,
0,
0.66... | [
"import unittest",
"from tests_algorithms import *",
"from tests_graphs import *",
"from tests_structures import *",
"if __name__ == '__main__':\n unittest.main()",
" unittest.main()"
] |
# -*- coding: utf-8 -*-
from graphs.listgraph import *
from graphs.matrixgraph import *
from graphs.generator import *
from timeit import Timer
class Main():
def __init__(self):
self.repeat = 5
def log(self, message):
print message
def measure(self):
start = 500
delta = ... | [
[
1,
0,
0.0115,
0.0057,
0,
0.66,
0,
217,
0,
1,
0,
0,
217,
0,
0
],
[
1,
0,
0.0172,
0.0057,
0,
0.66,
0.2,
941,
0,
1,
0,
0,
941,
0,
0
],
[
1,
0,
0.023,
0.0057,
0,
0.66... | [
"from graphs.listgraph import *",
"from graphs.matrixgraph import *",
"from graphs.generator import *",
"from timeit import Timer",
"class Main():\n\n def __init__(self):\n self.repeat = 5\n\n def log(self, message):\n print(message)",
" def __init__(self):\n self.repeat = 5"... |
# -*- coding: utf-8 -*-
import unittest
from structures.unionfind import UnionFind
class UnionFindTest(unittest.TestCase):
def test_create_unionfind(self):
unionfind = UnionFind(['V1', 'V2'])
self.assertEqual(2, unionfind.count())
def test_create_unionfind_union_check_count(self):
u... | [
[
1,
0,
0.0488,
0.0244,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0732,
0.0244,
0,
0.66,
0.5,
696,
0,
1,
0,
0,
696,
0,
0
],
[
3,
0,
0.5732,
0.878,
0,
0.66,
... | [
"import unittest",
"from structures.unionfind import UnionFind",
"class UnionFindTest(unittest.TestCase):\n\n def test_create_unionfind(self):\n unionfind = UnionFind(['V1', 'V2'])\n\n self.assertEqual(2, unionfind.count())\n\n def test_create_unionfind_union_check_count(self):",
" def ... |
# -*- coding: utf-8 -*-
import unittest
from graphs.matrixgraph import MatrixGraph
class MatrixGraphTest(unittest.TestCase):
def setUp(self):
self.graph = MatrixGraph()
def test_add_two_vertices(self):
self.graph.add_vertex('V1')
self.graph.add_vertex('V2')
self.assertEqual(... | [
[
1,
0,
0.0377,
0.0189,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0566,
0.0189,
0,
0.66,
0.5,
941,
0,
1,
0,
0,
941,
0,
0
],
[
3,
0,
0.5566,
0.9057,
0,
0.66,... | [
"import unittest",
"from graphs.matrixgraph import MatrixGraph",
"class MatrixGraphTest(unittest.TestCase):\n\n def setUp(self):\n self.graph = MatrixGraph()\n\n def test_add_two_vertices(self):\n self.graph.add_vertex('V1')\n self.graph.add_vertex('V2')",
" def setUp(self):\n ... |
# -*- coding: utf-8 -*-
import unittest
from structures.hashtable import HashTable
class HashTableTest(unittest.TestCase):
def test_add_and_retrieve_item(self):
hash = HashTable()
key = "one"
hash.set(key, 1)
self.assertEqual(1, hash.get(key))
def test_add_and_retrieve_two_i... | [
[
1,
0,
0.0222,
0.0111,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0333,
0.0111,
0,
0.66,
0.5,
112,
0,
1,
0,
0,
112,
0,
0
],
[
3,
0,
0.5333,
0.9444,
0,
0.66,... | [
"import unittest",
"from structures.hashtable import HashTable",
"class HashTableTest(unittest.TestCase):\n\n def test_add_and_retrieve_item(self):\n hash = HashTable()\n key = \"one\"\n hash.set(key, 1)\n\n self.assertEqual(1, hash.get(key))",
" def test_add_and_retrieve_ite... |
# -*- coding: utf-8 -*-
import unittest
from structures.list import List
class ListTest(unittest.TestCase):
def test_create_list_check_empty(self):
list = List()
self.assertTrue(list.empty())
def test_create_list_add_element_check_emtpy(self):
list = List()
list.add(1)
... | [
[
1,
0,
0.0339,
0.0169,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0508,
0.0169,
0,
0.66,
0.5,
593,
0,
1,
0,
0,
593,
0,
0
],
[
3,
0,
0.5508,
0.9153,
0,
0.66,... | [
"import unittest",
"from structures.list import List",
"class ListTest(unittest.TestCase):\n\n def test_create_list_check_empty(self):\n list = List()\n\n self.assertTrue(list.empty())\n\n def test_create_list_add_element_check_emtpy(self):",
" def test_create_list_check_empty(self):\n ... |
# -*- coding: utf-8 -*-
import unittest
from graphs.listgraph import ListGraph
class ListGraphTest(unittest.TestCase):
def setUp(self):
self.graph = ListGraph()
def test_add_two_vertices(self):
self.graph.add_vertex('V1')
self.graph.add_vertex('V2')
self.assertEqual(2, self.... | [
[
1,
0,
0.037,
0.0185,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0556,
0.0185,
0,
0.66,
0.5,
217,
0,
1,
0,
0,
217,
0,
0
],
[
3,
0,
0.5556,
0.9074,
0,
0.66,
... | [
"import unittest",
"from graphs.listgraph import ListGraph",
"class ListGraphTest(unittest.TestCase):\n\n def setUp(self):\n self.graph = ListGraph()\n\n def test_add_two_vertices(self):\n self.graph.add_vertex('V1')\n self.graph.add_vertex('V2')",
" def setUp(self):\n sel... |
# -*- coding: utf-8 *-*
import unittest
from graphs.listgraph import ListGraph
from graphs.matrixgraph import MatrixGraph
class DijkstraTest(unittest.TestCase):
def test_dijkstra_matrix(self):
self.run_test1(MatrixGraph())
self.run_test2(MatrixGraph())
self.run_test3(MatrixGraph())
d... | [
[
1,
0,
0.0408,
0.0204,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0612,
0.0204,
0,
0.66,
0.3333,
217,
0,
1,
0,
0,
217,
0,
0
],
[
1,
0,
0.0816,
0.0204,
0,
0.... | [
"import unittest",
"from graphs.listgraph import ListGraph",
"from graphs.matrixgraph import MatrixGraph",
"class DijkstraTest(unittest.TestCase):\n\n def test_dijkstra_matrix(self):\n self.run_test1(MatrixGraph())\n self.run_test2(MatrixGraph())\n self.run_test3(MatrixGraph())\n\n ... |
# -*- coding: utf-8 *-*
import unittest
from graphs.listgraph import ListGraph
from graphs.matrixgraph import MatrixGraph
class KruskalTest(unittest.TestCase):
def test_kruskal_matrix(self):
self.run_test1(MatrixGraph())
self.run_test2(MatrixGraph())
self.run_test3(MatrixGraph())
def... | [
[
1,
0,
0.0286,
0.0143,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0429,
0.0143,
0,
0.66,
0.3333,
217,
0,
1,
0,
0,
217,
0,
0
],
[
1,
0,
0.0571,
0.0143,
0,
0.... | [
"import unittest",
"from graphs.listgraph import ListGraph",
"from graphs.matrixgraph import MatrixGraph",
"class KruskalTest(unittest.TestCase):\n\n def test_kruskal_matrix(self):\n self.run_test1(MatrixGraph())\n self.run_test2(MatrixGraph())\n self.run_test3(MatrixGraph())\n\n de... |
# -*- coding: utf-8 *-*
import unittest
from graphs.listgraph import ListGraph
from graphs.matrixgraph import MatrixGraph
class PrimTest(unittest.TestCase):
def test_prim_matrix(self):
self.run_test1(MatrixGraph())
self.run_test2(MatrixGraph())
self.run_test3(MatrixGraph())
def test_... | [
[
1,
0,
0.0286,
0.0143,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0429,
0.0143,
0,
0.66,
0.3333,
217,
0,
1,
0,
0,
217,
0,
0
],
[
1,
0,
0.0571,
0.0143,
0,
0.... | [
"import unittest",
"from graphs.listgraph import ListGraph",
"from graphs.matrixgraph import MatrixGraph",
"class PrimTest(unittest.TestCase):\n\n def test_prim_matrix(self):\n self.run_test1(MatrixGraph())\n self.run_test2(MatrixGraph())\n self.run_test3(MatrixGraph())\n\n def test... |
# -*- coding: utf-8 -*-
import unittest
from structures.heap import Heap
class HeapTest(unittest.TestCase):
def test_add_n_elements_verify_order(self):
heap = Heap()
n = 65
#Insert elements in reverse order
for i in range(n):
heap.insert(n - i, n - i)
#Then ve... | [
[
1,
0,
0.0513,
0.0256,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0769,
0.0256,
0,
0.66,
0.5,
909,
0,
1,
0,
0,
909,
0,
0
],
[
3,
0,
0.5769,
0.8718,
0,
0.66,... | [
"import unittest",
"from structures.heap import Heap",
"class HeapTest(unittest.TestCase):\n\n def test_add_n_elements_verify_order(self):\n heap = Heap()\n n = 65\n #Insert elements in reverse order\n for i in range(n):\n heap.insert(n - i, n - i)",
" def test_add... |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
from structures.list import List
from structures.heap import Heap
from structures.unionfind import UnionFind
from graphs.graph import *
class MatrixGraph(Graph):
def __init__(self):
self.__adjacency = []
self.__vertices = HashTabl... | [
[
1,
0,
0.0084,
0.0042,
0,
0.66,
0,
112,
0,
1,
0,
0,
112,
0,
0
],
[
1,
0,
0.0126,
0.0042,
0,
0.66,
0.2,
593,
0,
1,
0,
0,
593,
0,
0
],
[
1,
0,
0.0168,
0.0042,
0,
0.6... | [
"from structures.hashtable import HashTable",
"from structures.list import List",
"from structures.heap import Heap",
"from structures.unionfind import UnionFind",
"from graphs.graph import *",
"class MatrixGraph(Graph):\n\n def __init__(self):\n self.__adjacency = []\n self.__vertices = ... |
# -*- coding: utf-8 -*-
from structures.list import List
from structures.heap import Heap
from structures.unionfind import UnionFind
from graphs.graph import *
class ListGraph(Graph):
def __init__(self, size=None):
self.__vertices = HashTable(size)
def add_vertex(self, name):
self.__vertices... | [
[
1,
0,
0.0088,
0.0044,
0,
0.66,
0,
593,
0,
1,
0,
0,
593,
0,
0
],
[
1,
0,
0.0132,
0.0044,
0,
0.66,
0.25,
909,
0,
1,
0,
0,
909,
0,
0
],
[
1,
0,
0.0175,
0.0044,
0,
0.... | [
"from structures.list import List",
"from structures.heap import Heap",
"from structures.unionfind import UnionFind",
"from graphs.graph import *",
"class ListGraph(Graph):\n\n def __init__(self, size=None):\n self.__vertices = HashTable(size)\n\n def add_vertex(self, name):\n self.__ver... |
# -*- coding: utf-8 -*-
from graphs.matrixgraph import MatrixGraph
import random
import math
class Generator():
def __init__(self):
pass
def generate(self, vcount, factor, filename):
if factor > 1:
raise Exception('Invalid density factor.')
maxedges = (vcount - 1) * vcou... | [
[
1,
0,
0.0267,
0.0133,
0,
0.66,
0,
941,
0,
1,
0,
0,
941,
0,
0
],
[
1,
0,
0.04,
0.0133,
0,
0.66,
0.3333,
715,
0,
1,
0,
0,
715,
0,
0
],
[
1,
0,
0.0533,
0.0133,
0,
0.... | [
"from graphs.matrixgraph import MatrixGraph",
"import random",
"import math",
"class Generator():\n\n def __init__(self):\n pass\n\n def generate(self, vcount, factor, filename):\n if factor > 1:\n raise Exception('Invalid density factor.')",
" def __init__(self):\n ... |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
class Graph():
NAME_SEPARATOR = '->'
ADJ_LIST_SEPARATOR = '||'
WEIGHT_SEPARATOR = ';'
def __init__(self):
pass
def load(self, filename):
pass
def save(self, filename):
raise Exception('save() not imp... | [
[
1,
0,
0.0476,
0.0238,
0,
0.66,
0,
112,
0,
1,
0,
0,
112,
0,
0
],
[
3,
0,
0.5595,
0.9048,
0,
0.66,
1,
90,
0,
11,
0,
0,
0,
0,
3
],
[
14,
1,
0.1667,
0.0238,
1,
0.11,
... | [
"from structures.hashtable import HashTable",
"class Graph():\n\n NAME_SEPARATOR = '->'\n ADJ_LIST_SEPARATOR = '||'\n WEIGHT_SEPARATOR = ';'\n\n def __init__(self):\n pass",
" NAME_SEPARATOR = '->'",
" ADJ_LIST_SEPARATOR = '||'",
" WEIGHT_SEPARATOR = ';'",
" def __init__(sel... |
# -*- coding: utf-8 -*-
import sys
import unittest
from tests.matrixgraph import *
from tests.listgraph import *
if __name__ == '__main__':
unittest.main()
| [
[
1,
0,
0.2222,
0.1111,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.3333,
0.1111,
0,
0.66,
0.25,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.5556,
0.1111,
0,
0.66... | [
"import sys",
"import unittest",
"from tests.matrixgraph import *",
"from tests.listgraph import *",
"if __name__ == '__main__':\n unittest.main()",
" unittest.main()"
] |
# -*- coding: utf-8 -*-
import sys
import unittest
from tests.hashtable import *
from tests.heap import *
from tests.unionfind import *
from tests.list import *
if __name__ == '__main__':
unittest.main()
| [
[
1,
0,
0.1818,
0.0909,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.2727,
0.0909,
0,
0.66,
0.1667,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.4545,
0.0909,
0,
0.... | [
"import sys",
"import unittest",
"from tests.hashtable import *",
"from tests.heap import *",
"from tests.unionfind import *",
"from tests.list import *",
"if __name__ == '__main__':\n unittest.main()",
" unittest.main()"
] |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
class UnionFind():
def __init__(self, items):
self.sets = HashTable()
for item in items:
node = [item, None, 1]
self.sets[item] = node
self.__count = len(items)
def find(self, item):
no... | [
[
1,
0,
0.0476,
0.0238,
0,
0.66,
0,
112,
0,
1,
0,
0,
112,
0,
0
],
[
3,
0,
0.4643,
0.7143,
0,
0.66,
1,
845,
0,
4,
0,
0,
0,
0,
2
],
[
2,
1,
0.2262,
0.1429,
1,
0.68,
... | [
"from structures.hashtable import HashTable",
"class UnionFind():\n\n def __init__(self, items):\n self.sets = HashTable()\n for item in items:\n node = [item, None, 1]\n self.sets[item] = node\n self.__count = len(items)",
" def __init__(self, items):\n s... |
# -*- coding: utf-8 -*-
class HashTable():
__initial_size = 10000
def __init__(self, size=None):
self.__size = size
if size is None:
self.__size = HashTable.__initial_size
self.items = [None] * self.__size
self.__keys = []
def count(self):
return len... | [
[
3,
0,
0.5149,
0.9776,
0,
0.66,
0,
631,
0,
16,
0,
0,
0,
0,
25
],
[
14,
1,
0.0373,
0.0075,
1,
0.08,
0,
323,
1,
0,
0,
0,
0,
1,
0
],
[
2,
1,
0.0784,
0.0597,
1,
0.08,
... | [
"class HashTable():\n __initial_size = 10000\n\n def __init__(self, size=None):\n self.__size = size\n\n if size is None:\n self.__size = HashTable.__initial_size",
" __initial_size = 10000",
" def __init__(self, size=None):\n self.__size = size\n\n if size is ... |
# -*- coding: utf-8 -*-
class List():
def __init__(self):
self.__begin = None
self.__end = None
self.__current = None
self.__size = 0
def empty(self):
return self.__size == 0
def pop(self):
return self.pop_last()
def pop_last(self):
item = No... | [
[
3,
0,
0.4071,
0.7643,
0,
0.66,
0,
24,
0,
17,
0,
0,
0,
0,
4
],
[
2,
1,
0.0571,
0.0357,
1,
0.73,
0,
555,
0,
1,
0,
0,
0,
0,
0
],
[
14,
2,
0.05,
0.0071,
2,
0.54,
... | [
"class List():\n\n def __init__(self):\n self.__begin = None\n self.__end = None\n self.__current = None\n self.__size = 0",
" def __init__(self):\n self.__begin = None\n self.__end = None\n self.__current = None\n self.__size = 0",
" self.__b... |
# -*- coding: utf-8 -*-
class Heap():
__maxSize = 100
def __init__(self):
self.items = []
def insert(self, key, data):
item = [key, data]
self.items.append(item)
index = len(self.items) - 1
self.__heapify_up(index)
def change_key(self, index, key):
se... | [
[
3,
0,
0.5155,
0.9767,
0,
0.66,
0,
538,
0,
18,
0,
0,
0,
0,
37
],
[
14,
1,
0.0388,
0.0078,
1,
0.57,
0,
822,
1,
0,
0,
0,
0,
1,
0
],
[
2,
1,
0.0581,
0.0155,
1,
0.57,
... | [
"class Heap():\n __maxSize = 100\n\n def __init__(self):\n self.items = []\n\n def insert(self, key, data):\n item = [key, data]",
" __maxSize = 100",
" def __init__(self):\n self.items = []",
" self.items = []",
" def insert(self, key, data):\n item = [k... |
# -*- coding: utf-8 *-*
class DBActors():
def __init__(self, filename):
self.filename = filename
self.file = None
self.currentline = None
def open(self):
if self.file is None:
self.file = open(self.filename)
# Read file until the start of actor/actres... | [
[
3,
0,
0.5253,
0.962,
0,
0.66,
0,
402,
0,
11,
0,
0,
0,
0,
21
],
[
2,
1,
0.0949,
0.0506,
1,
0.27,
0,
555,
0,
2,
0,
0,
0,
0,
0
],
[
14,
2,
0.0886,
0.0127,
2,
0.67,
... | [
"class DBActors():\n\n def __init__(self, filename):\n self.filename = filename\n self.file = None\n self.currentline = None\n\n def open(self):",
" def __init__(self, filename):\n self.filename = filename\n self.file = None\n self.currentline = None",
" ... |
# -*- coding: utf-8 *-*
from structures.hashtable import HashTable
class Actor():
def __init__(self, name):
self.name = name
self.__titlesHash = HashTable()
self.titles = []
def add_title(self, title):
if self.__titlesHash[title] is None:
self.__titlesHash[title] ... | [
[
1,
0,
0.0909,
0.0455,
0,
0.66,
0,
112,
0,
1,
0,
0,
112,
0,
0
],
[
3,
0,
0.6136,
0.8182,
0,
0.66,
1,
985,
0,
3,
0,
0,
0,
0,
2
],
[
2,
1,
0.3864,
0.1818,
1,
0.34,
... | [
"from structures.hashtable import HashTable",
"class Actor():\n\n def __init__(self, name):\n self.name = name\n self.__titlesHash = HashTable()\n self.titles = []\n\n def add_title(self, title):",
" def __init__(self, name):\n self.name = name\n self.__titlesHash = H... |
# -*- coding: utf-8 *-*
from structures.hashtable import HashTable
class Movie():
def __init__(self, title):
self.title = title
self.actors = HashTable()
def add_actor(self, actor):
if self.actors[actor] is None:
self.actors[actor] = True
| [
[
1,
0,
0.1538,
0.0769,
0,
0.66,
0,
112,
0,
1,
0,
0,
112,
0,
0
],
[
3,
0,
0.6923,
0.6923,
0,
0.66,
1,
945,
0,
2,
0,
0,
0,
0,
1
],
[
2,
1,
0.6154,
0.2308,
1,
0.88,
... | [
"from structures.hashtable import HashTable",
"class Movie():\n\n def __init__(self, title):\n self.title = title\n self.actors = HashTable()\n\n def add_actor(self, actor):\n if self.actors[actor] is None:",
" def __init__(self, title):\n self.title = title\n self.ac... |
# -*- coding: utf-8 *-*
from graphs.listgraph import *
def add_edge(g, src, dest):
g.add_edge(src, dest, 1)
g.add_edge(dest, src, 1)
def generate_test1():
graph = ListGraph()
graph.add_vertex('A')
graph.add_vertex('B')
graph.add_vertex('C')
graph.add_vertex('D')
graph.add_vertex('E... | [
[
1,
0,
0.0244,
0.0122,
0,
0.66,
0,
217,
0,
1,
0,
0,
217,
0,
0
],
[
2,
0,
0.0732,
0.0366,
0,
0.66,
0.1111,
76,
0,
3,
0,
0,
0,
0,
2
],
[
8,
1,
0.0732,
0.0122,
1,
0.4... | [
"from graphs.listgraph import *",
"def add_edge(g, src, dest):\n g.add_edge(src, dest, 1)\n g.add_edge(dest, src, 1)",
" g.add_edge(src, dest, 1)",
" g.add_edge(dest, src, 1)",
"def generate_test1():\n\n graph = ListGraph()\n\n graph.add_vertex('A')\n graph.add_vertex('B')\n graph.ad... |
# -*- coding: utf-8 *-*
import sys
import unittest
from tests.dijkstra import *
if __name__ == '__main__':
unittest.main()
| [
[
1,
0,
0.25,
0.125,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.375,
0.125,
0,
0.66,
0.3333,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.625,
0.125,
0,
0.66,
... | [
"import sys",
"import unittest",
"from tests.dijkstra import *",
"if __name__ == '__main__':\n unittest.main()",
" unittest.main()"
] |
# -*- coding: utf-8 *-*
import unittest
from tests_algorithms import *
from tests_graphs import *
from tests_structures import *
if __name__ == '__main__':
unittest.main()
| [
[
1,
0,
0.2222,
0.1111,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.4444,
0.1111,
0,
0.66,
0.25,
222,
0,
1,
0,
0,
222,
0,
0
],
[
1,
0,
0.5556,
0.1111,
0,
0.66... | [
"import unittest",
"from tests_algorithms import *",
"from tests_graphs import *",
"from tests_structures import *",
"if __name__ == '__main__':\n unittest.main()",
" unittest.main()"
] |
# -*- coding: utf-8 *-*
from graphs.matrixgraph import *
from graphs.listgraph import *
from structures.hashtable import HashTable
from imdb.dbactors import DBActors
# Total
# Around 1450000 actors
# Around 819000 actresses
# RAM: 524.8 MB
class Main():
def __init__(self):
pass
def main(self):
... | [
[
1,
0,
0.015,
0.0075,
0,
0.66,
0,
941,
0,
1,
0,
0,
941,
0,
0
],
[
1,
0,
0.0226,
0.0075,
0,
0.66,
0.2,
217,
0,
1,
0,
0,
217,
0,
0
],
[
1,
0,
0.0301,
0.0075,
0,
0.66... | [
"from graphs.matrixgraph import *",
"from graphs.listgraph import *",
"from structures.hashtable import HashTable",
"from imdb.dbactors import DBActors",
"class Main():\n\n def __init__(self):\n pass\n\n def main(self):\n filenames = ['C:/Juan/imdb/actors.list', 'C:/Juan/imdb/actresses.l... |
# -*- coding: utf-8 -*-
import unittest
from structures.unionfind import UnionFind
class UnionFindTest(unittest.TestCase):
def test_create_unionfind(self):
unionfind = UnionFind(['V1', 'V2'])
self.assertEqual(2, unionfind.count())
def test_create_unionfind_union_check_count(self):
u... | [
[
1,
0,
0.0488,
0.0244,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0732,
0.0244,
0,
0.66,
0.5,
696,
0,
1,
0,
0,
696,
0,
0
],
[
3,
0,
0.5732,
0.878,
0,
0.66,
... | [
"import unittest",
"from structures.unionfind import UnionFind",
"class UnionFindTest(unittest.TestCase):\n\n def test_create_unionfind(self):\n unionfind = UnionFind(['V1', 'V2'])\n\n self.assertEqual(2, unionfind.count())\n\n def test_create_unionfind_union_check_count(self):",
" def ... |
# -*- coding: utf-8 -*-
import unittest
from graphs.matrixgraph import MatrixGraph
class MatrixGraphTest(unittest.TestCase):
def setUp(self):
self.graph = MatrixGraph()
def test_add_two_vertices(self):
self.graph.add_vertex('V1')
self.graph.add_vertex('V2')
self.assertEqual(... | [
[
1,
0,
0.037,
0.0185,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0556,
0.0185,
0,
0.66,
0.5,
941,
0,
1,
0,
0,
941,
0,
0
],
[
3,
0,
0.5556,
0.9074,
0,
0.66,
... | [
"import unittest",
"from graphs.matrixgraph import MatrixGraph",
"class MatrixGraphTest(unittest.TestCase):\n\n def setUp(self):\n self.graph = MatrixGraph()\n\n def test_add_two_vertices(self):\n self.graph.add_vertex('V1')\n self.graph.add_vertex('V2')",
" def setUp(self):\n ... |
# -*- coding: utf-8 -*-
import unittest
from structures.hashtable import HashTable
class HashTableTest(unittest.TestCase):
def test_add_and_retrieve_item(self):
hash = HashTable()
key = "one"
hash.set(key, 1)
self.assertEqual(1, hash.get(key))
def test_add_and_retrieve_two_i... | [
[
1,
0,
0.0222,
0.0111,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0333,
0.0111,
0,
0.66,
0.5,
112,
0,
1,
0,
0,
112,
0,
0
],
[
3,
0,
0.5333,
0.9444,
0,
0.66,... | [
"import unittest",
"from structures.hashtable import HashTable",
"class HashTableTest(unittest.TestCase):\n\n def test_add_and_retrieve_item(self):\n hash = HashTable()\n key = \"one\"\n hash.set(key, 1)\n\n self.assertEqual(1, hash.get(key))",
" def test_add_and_retrieve_ite... |
# -*- coding: utf-8 -*-
import unittest
from structures.list import List
class ListTest(unittest.TestCase):
def test_create_list_check_empty(self):
list = List()
self.assertTrue(list.empty())
def test_create_list_add_element_check_emtpy(self):
list = List()
list.add(1)
... | [
[
1,
0,
0.0339,
0.0169,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0508,
0.0169,
0,
0.66,
0.5,
593,
0,
1,
0,
0,
593,
0,
0
],
[
3,
0,
0.5508,
0.9153,
0,
0.66,... | [
"import unittest",
"from structures.list import List",
"class ListTest(unittest.TestCase):\n\n def test_create_list_check_empty(self):\n list = List()\n\n self.assertTrue(list.empty())\n\n def test_create_list_add_element_check_emtpy(self):",
" def test_create_list_check_empty(self):\n ... |
# -*- coding: utf-8 -*-
import unittest
from graphs.listgraph import ListGraph
class ListGraphTest(unittest.TestCase):
def setUp(self):
self.graph = ListGraph()
def test_add_two_vertices(self):
self.graph.add_vertex('V1')
self.graph.add_vertex('V2')
self.assertEqual(2, self.... | [
[
1,
0,
0.0364,
0.0182,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0545,
0.0182,
0,
0.66,
0.5,
217,
0,
1,
0,
0,
217,
0,
0
],
[
3,
0,
0.5545,
0.9091,
0,
0.66,... | [
"import unittest",
"from graphs.listgraph import ListGraph",
"class ListGraphTest(unittest.TestCase):\n\n def setUp(self):\n self.graph = ListGraph()\n\n def test_add_two_vertices(self):\n self.graph.add_vertex('V1')\n self.graph.add_vertex('V2')",
" def setUp(self):\n sel... |
# -*- coding: utf-8 *-*
import unittest
from graphs.listgraph import ListGraph
from graphs.matrixgraph import MatrixGraph
class DijkstraTest(unittest.TestCase):
def test_dijkstra_matrix(self):
self.run_test1(MatrixGraph())
self.run_test2(MatrixGraph())
self.run_test3(MatrixGraph())
... | [
[
1,
0,
0.0328,
0.0164,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0492,
0.0164,
0,
0.66,
0.3333,
217,
0,
1,
0,
0,
217,
0,
0
],
[
1,
0,
0.0656,
0.0164,
0,
0.... | [
"import unittest",
"from graphs.listgraph import ListGraph",
"from graphs.matrixgraph import MatrixGraph",
"class DijkstraTest(unittest.TestCase):\n\n def test_dijkstra_matrix(self):\n self.run_test1(MatrixGraph())\n self.run_test2(MatrixGraph())\n self.run_test3(MatrixGraph())\n ... |
# -*- coding: utf-8 -*-
import unittest
from structures.heap import Heap
class HeapTest(unittest.TestCase):
def test_add_n_elements_verify_order(self):
heap = Heap()
n = 65
#Insert elements in reverse order
for i in range(n):
heap.insert(n - i, n - i)
#Then ve... | [
[
1,
0,
0.0513,
0.0256,
0,
0.66,
0,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.0769,
0.0256,
0,
0.66,
0.5,
909,
0,
1,
0,
0,
909,
0,
0
],
[
3,
0,
0.5769,
0.8718,
0,
0.66,... | [
"import unittest",
"from structures.heap import Heap",
"class HeapTest(unittest.TestCase):\n\n def test_add_n_elements_verify_order(self):\n heap = Heap()\n n = 65\n #Insert elements in reverse order\n for i in range(n):\n heap.insert(n - i, n - i)",
" def test_add... |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
from structures.list import List
from structures.heap import Heap
from structures.unionfind import UnionFind
from graphs.graph import *
class MatrixGraph(Graph):
def __init__(self):
self.__adjacency = []
self.__vertices = HashTabl... | [
[
1,
0,
0.0137,
0.0068,
0,
0.66,
0,
112,
0,
1,
0,
0,
112,
0,
0
],
[
1,
0,
0.0205,
0.0068,
0,
0.66,
0.2,
593,
0,
1,
0,
0,
593,
0,
0
],
[
1,
0,
0.0274,
0.0068,
0,
0.6... | [
"from structures.hashtable import HashTable",
"from structures.list import List",
"from structures.heap import Heap",
"from structures.unionfind import UnionFind",
"from graphs.graph import *",
"class MatrixGraph(Graph):\n\n def __init__(self):\n self.__adjacency = []\n self.__vertices = ... |
# -*- coding: utf-8 -*-
from structures.list import List
from structures.heap import Heap
from structures.unionfind import UnionFind
from graphs.graph import *
class ListGraph(Graph):
def __init__(self, size=None):
self.__vertices = HashTable(size)
def add_vertex(self, name):
self.__vertices... | [
[
1,
0,
0.0131,
0.0065,
0,
0.66,
0,
593,
0,
1,
0,
0,
593,
0,
0
],
[
1,
0,
0.0196,
0.0065,
0,
0.66,
0.25,
909,
0,
1,
0,
0,
909,
0,
0
],
[
1,
0,
0.0261,
0.0065,
0,
0.... | [
"from structures.list import List",
"from structures.heap import Heap",
"from structures.unionfind import UnionFind",
"from graphs.graph import *",
"class ListGraph(Graph):\n\n def __init__(self, size=None):\n self.__vertices = HashTable(size)\n\n def add_vertex(self, name):\n self.__ver... |
# -*- coding: utf-8 -*-
from graphs.matrixgraph import MatrixGraph
from graphs.graph import Edge
import random
import math
class Generator():
def __init__(self):
pass
def generate(self, vcount, factor, filename):
if factor > 1:
raise Exception('Invalid density factor.')
... | [
[
1,
0,
0.027,
0.0135,
0,
0.66,
0,
941,
0,
1,
0,
0,
941,
0,
0
],
[
1,
0,
0.0405,
0.0135,
0,
0.66,
0.25,
628,
0,
1,
0,
0,
628,
0,
0
],
[
1,
0,
0.0541,
0.0135,
0,
0.6... | [
"from graphs.matrixgraph import MatrixGraph",
"from graphs.graph import Edge",
"import random",
"import math",
"class Generator():\n\n def __init__(self):\n pass\n\n def generate(self, vcount, factor, filename):\n if factor > 1:\n raise Exception('Invalid density factor.')",
... |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
class Graph():
NAME_SEPARATOR = '->'
ADJ_LIST_SEPARATOR = '||'
WEIGHT_SEPARATOR = ';'
def __init__(self):
pass
def load(self, filename):
pass
def save(self, filename):
raise Exception('save() not imp... | [
[
1,
0,
0.0476,
0.0238,
0,
0.66,
0,
112,
0,
1,
0,
0,
112,
0,
0
],
[
3,
0,
0.5595,
0.9048,
0,
0.66,
1,
90,
0,
11,
0,
0,
0,
0,
3
],
[
14,
1,
0.1667,
0.0238,
1,
0.07,
... | [
"from structures.hashtable import HashTable",
"class Graph():\n\n NAME_SEPARATOR = '->'\n ADJ_LIST_SEPARATOR = '||'\n WEIGHT_SEPARATOR = ';'\n\n def __init__(self):\n pass",
" NAME_SEPARATOR = '->'",
" ADJ_LIST_SEPARATOR = '||'",
" WEIGHT_SEPARATOR = ';'",
" def __init__(sel... |
# -*- coding: utf-8 -*-
import sys
import unittest
from tests.matrixgraph import *
from tests.listgraph import *
if __name__ == '__main__':
unittest.main()
| [
[
1,
0,
0.2222,
0.1111,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.3333,
0.1111,
0,
0.66,
0.25,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.5556,
0.1111,
0,
0.66... | [
"import sys",
"import unittest",
"from tests.matrixgraph import *",
"from tests.listgraph import *",
"if __name__ == '__main__':\n unittest.main()",
" unittest.main()"
] |
# -*- coding: utf-8 -*-
import sys
import unittest
from tests.hashtable import *
from tests.heap import *
from tests.unionfind import *
from tests.list import *
if __name__ == '__main__':
unittest.main()
| [
[
1,
0,
0.1818,
0.0909,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.2727,
0.0909,
0,
0.66,
0.1667,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.4545,
0.0909,
0,
0.... | [
"import sys",
"import unittest",
"from tests.hashtable import *",
"from tests.heap import *",
"from tests.unionfind import *",
"from tests.list import *",
"if __name__ == '__main__':\n unittest.main()",
" unittest.main()"
] |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
class UnionFind():
def __init__(self, items):
self.sets = HashTable()
for item in items:
node = UnionFindNode(item)
self.sets.set(item, node)
self.__count = len(items)
def find(self, item):
... | [
[
1,
0,
0.0476,
0.0238,
0,
0.66,
0,
112,
0,
1,
0,
0,
112,
0,
0
],
[
3,
0,
0.4643,
0.7143,
0,
0.66,
0.5,
845,
0,
4,
0,
0,
0,
0,
7
],
[
2,
1,
0.2262,
0.1429,
1,
0.29,... | [
"from structures.hashtable import HashTable",
"class UnionFind():\n\n def __init__(self, items):\n self.sets = HashTable()\n for item in items:\n node = UnionFindNode(item)\n self.sets.set(item, node)\n self.__count = len(items)",
" def __init__(self, items):\n ... |
# -*- coding: utf-8 -*-
class HashTable():
__initial_size = 32
def __init__(self, size=None):
self.__size = size
if size is None:
self.__size = HashTable.__initial_size
self.items = [None] * self.__size
self.__keys = []
def count(self):
return len(se... | [
[
3,
0,
0.5149,
0.9776,
0,
0.66,
0,
631,
0,
16,
0,
0,
0,
0,
25
],
[
14,
1,
0.0373,
0.0075,
1,
0.12,
0,
323,
1,
0,
0,
0,
0,
1,
0
],
[
2,
1,
0.0784,
0.0597,
1,
0.12,
... | [
"class HashTable():\n __initial_size = 32\n\n def __init__(self, size=None):\n self.__size = size\n\n if size is None:\n self.__size = HashTable.__initial_size",
" __initial_size = 32",
" def __init__(self, size=None):\n self.__size = size\n\n if size is None:\... |
# -*- coding: utf-8 -*-
class List():
def __init__(self):
self.__begin = None
self.__end = None
self.__current = None
self.__size = 0
def empty(self):
return self.__size == 0
def pop(self):
return self.pop_last()
def pop_last(self):
item = No... | [
[
3,
0,
0.4071,
0.7643,
0,
0.66,
0,
24,
0,
17,
0,
0,
0,
0,
4
],
[
2,
1,
0.0571,
0.0357,
1,
0.35,
0,
555,
0,
1,
0,
0,
0,
0,
0
],
[
14,
2,
0.05,
0.0071,
2,
0.52,
... | [
"class List():\n\n def __init__(self):\n self.__begin = None\n self.__end = None\n self.__current = None\n self.__size = 0",
" def __init__(self):\n self.__begin = None\n self.__end = None\n self.__current = None\n self.__size = 0",
" self.__b... |
# -*- coding: utf-8 -*-
class Heap():
__maxSize = 100
def __init__(self):
self.items = []
def insert(self, key, data):
item = HeapItem(key, data)
self.items.append(item)
index = len(self.items) - 1
self.__heapify_up(index)
def change_key(self, index, key):
... | [
[
3,
0,
0.489,
0.9265,
0,
0.66,
0,
538,
0,
18,
0,
0,
0,
0,
38
],
[
14,
1,
0.0368,
0.0074,
1,
0.4,
0,
822,
1,
0,
0,
0,
0,
1,
0
],
[
2,
1,
0.0551,
0.0147,
1,
0.4,
... | [
"class Heap():\n __maxSize = 100\n\n def __init__(self):\n self.items = []\n\n def insert(self, key, data):\n item = HeapItem(key, data)",
" __maxSize = 100",
" def __init__(self):\n self.items = []",
" self.items = []",
" def insert(self, key, data):\n i... |
# -*- coding: utf-8 -*-
###############################################################################
# Import Modules
###############################################################################
import sys
import unittest
from backtracking import backtracking
from galeshapley import galeshapley
class TdaTP1(uni... | [
[
1,
0,
0.0847,
0.0169,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.1017,
0.0169,
0,
0.66,
0.2,
88,
0,
1,
0,
0,
88,
0,
0
],
[
1,
0,
0.1186,
0.0169,
0,
0.66,... | [
"import sys",
"import unittest",
"from backtracking import backtracking",
"from galeshapley import galeshapley",
"class TdaTP1(unittest.TestCase):\n\n def getOutput(self, filename):\n outputFile = file(filename)\n return outputFile.read()\n\n def getGaleShapley(self, filename):\n ... |
# -*- coding: utf-8 -*-
###############################################################################
# Import Modules
###############################################################################
import sys
from backtracking import backtracking
from galeshapley import galeshapley
def compareResult(filename, resu... | [
[
1,
0,
0.0877,
0.0175,
0,
0.66,
0,
509,
0,
1,
0,
0,
509,
0,
0
],
[
1,
0,
0.1053,
0.0175,
0,
0.66,
0.1667,
481,
0,
1,
0,
0,
481,
0,
0
],
[
1,
0,
0.1228,
0.0175,
0,
... | [
"import sys",
"from backtracking import backtracking",
"from galeshapley import galeshapley",
"def compareResult(filename, resultStr):\n outputFile = file(filename)\n outputStr = outputFile.read()\n if outputStr == resultStr:\n print(\"Sucess! The result matches the file contents for:\", filen... |
# -*- coding: utf-8 -*-
from collections import deque
from model.person import Person
from model.solution import Solution
class Backtracking:
def __init__(self, filename):
self.men = deque()
self.women = []
self.solution = None
self.__temp = Solution()
self.load_data(filen... | [
[
1,
0,
0.0339,
0.0169,
0,
0.66,
0,
193,
0,
1,
0,
0,
193,
0,
0
],
[
1,
0,
0.0508,
0.0169,
0,
0.66,
0.3333,
231,
0,
1,
0,
0,
231,
0,
0
],
[
1,
0,
0.0678,
0.0169,
0,
... | [
"from collections import deque",
"from model.person import Person",
"from model.solution import Solution",
"class Backtracking:\n\n def __init__(self, filename):\n self.men = deque()\n self.women = []\n self.solution = None\n self.__temp = Solution()\n self.load_data(file... |
# -*- coding: utf-8 -*-
from collections import deque
from model.person import Person
from model.solution import Solution
class GaleShapley:
def __init__(self, filename):
self.singles = deque()
self.men = []
self.women = dict()
self.load_data(filename)
def load_data(self, fi... | [
[
1,
0,
0.0317,
0.0159,
0,
0.66,
0,
193,
0,
1,
0,
0,
193,
0,
0
],
[
1,
0,
0.0476,
0.0159,
0,
0.66,
0.3333,
231,
0,
1,
0,
0,
231,
0,
0
],
[
1,
0,
0.0635,
0.0159,
0,
... | [
"from collections import deque",
"from model.person import Person",
"from model.solution import Solution",
"class GaleShapley:\n\n def __init__(self, filename):\n self.singles = deque()\n self.men = []\n self.women = dict()\n\n self.load_data(filename)",
" def __init__(self... |
# -*- coding: utf-8 -*-
from collections import deque
class Solution:
def __init__(self):
self.__pairs = deque()
def is_stable(self, pair):
for p in self.__pairs:
m1 = p[0]
w1 = p[1]
m2 = pair[0]
w2 = pair[1]
if ((m1.prefers(w2) an... | [
[
1,
0,
0.0833,
0.0278,
0,
0.66,
0,
193,
0,
1,
0,
0,
193,
0,
0
],
[
3,
0,
0.5833,
0.8611,
0,
0.66,
1,
659,
0,
6,
0,
0,
0,
0,
9
],
[
2,
1,
0.2361,
0.0556,
1,
0.84,
... | [
"from collections import deque",
"class Solution:\n\n def __init__(self):\n self.__pairs = deque()\n\n def is_stable(self, pair):\n for p in self.__pairs:\n m1 = p[0]",
" def __init__(self):\n self.__pairs = deque()",
" self.__pairs = deque()",
" def is_sta... |
# -*- coding: utf-8 -*-
from collections import deque
class Person:
def __init__(self, name, preferences=[]):
"""Initializes the preferences hashtable.
O(n)"""
self.prefnames = deque()
self.name = name
self.fiancee = None
self.prefs = dict()
i = 0
f... | [
[
1,
0,
0.0465,
0.0233,
0,
0.66,
0,
193,
0,
1,
0,
0,
193,
0,
0
],
[
3,
0,
0.5581,
0.907,
0,
0.66,
1,
362,
0,
5,
0,
0,
0,
0,
7
],
[
2,
1,
0.3023,
0.3023,
1,
0.27,
... | [
"from collections import deque",
"class Person:\n\n def __init__(self, name, preferences=[]):\n \"\"\"Initializes the preferences hashtable.\n O(n)\"\"\"\n self.prefnames = deque()\n self.name = name\n self.fiancee = None",
" def __init__(self, name, preferences=[]):\n ... |
__author__="Sergey Karakovskiy, sergey at idsia fullstop ch"
__date__ ="$Feb 18, 2009 1:01:12 AM$"
class SimplePyAgent:
# class MarioAgent(Agent):
""" example of usage of AmiCo
"""
def getAction(self, obs):
ret = (0, 1, 0, 0, 0)
return ret
def giveReward(self, reward):
pass... | [
[
14,
0,
0.0286,
0.0286,
0,
0.66,
0,
777,
1,
0,
0,
0,
0,
3,
0
],
[
14,
0,
0.0571,
0.0286,
0,
0.66,
0.5,
763,
1,
0,
0,
0,
0,
3,
0
],
[
3,
0,
0.5286,
0.8571,
0,
0.66,... | [
"__author__=\"Sergey Karakovskiy, sergey at idsia fullstop ch\"",
"__date__ =\"$Feb 18, 2009 1:01:12 AM$\"",
"class SimplePyAgent:\n# class MarioAgent(Agent):\n \"\"\" example of usage of AmiCo\n \"\"\"\n\n def getAction(self, obs):\n ret = (0, 1, 0, 0, 0)\n return ret",
" \"\"\" ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.