def main(): data = np.genfromtxt('Data/Sudoku.csv', delimiter=';', names=True, dtype=('>i4', '>i4', '|U81', '|U81')) sudokus = [Sudoku(i) for i in data] times = [] sudokus = sudokus[:4] for sudoku in sudokus: start = timer() solve(sudoku.grid) print(str(sudoku.is_solved())) end = timer() times.append(end - start) x = np.linspace(1, len(sudokus), len(sudokus)) y = times for xx, yy in zip(x, y): label = '{:.2f}'.format(yy) plt.annotate(label, (xx, yy), textcoords='offset points', xytext=(0, 10), ha='center') plt.scatter(x, y) plt.xticks(np.arange(min(x), max(x) + 1, 1)) plt.title('Time to solve') plt.xlabel('Puzzle no.') plt.ylabel('Time (s)') plt.show()
def main(): starting_state = state_tree.build_state_from_grid(example_grid) solution = solve(starting_state) print("Here's the solution:") for line in solution: print(line) return
def main(start='', genetic=False): zip_code() for p in get_prob_names(start): prob = read_file(p) solve(prob, genetic) prob.prepare_for_output() if False: print(prob.score()) print('---- CUT HERE ----') prob.output_sol(sys.stdout) with open('0_sol_' + p, 'w') as f: prob.output_sol(f)
def test_findall(self): solve(findall(or_(prin(1), prin(2))))
md.cluster = cluster if clustername != gethostname(): md.cluster.interactive = 0 md.settings.waitonlock = 0 else: md.cluster.interactive = 1 md.settings.waitonlock = math.inf md.transient.requested_outputs = [ 'TotalSmb', 'SmbMassBalance', 'IceVolume', 'IceVolumeAboveFloatation', 'IceVolumeAboveFloatationScaled', 'GroundedAreaScaled', 'FloatingAreaScaled', 'IceMass', 'GroundedArea', 'FloatingArea', 'TotalFloatingBmb', 'BasalforcingsFloatingiceMeltingRate', 'Calvingratex', 'Calvingratey', 'CalvingCalvingrate', 'TotalCalvingFluxLevelset' ] md = solve(md, which_run[run_type][3], 'runtimename', 0) # }}} # Retriever {{{ elif launch_or_get == 'r': print('retreiving') md = getattr(my_Runner2, which_run[run_type][1])(params, run_name, load_name) md.cluster = cluster md = loadresultsfromcluster(md, run_name) export_netCDF(md, model_name) #exportVTK(vtk_name, md, 'geometry', 'mesh','mask', 'stressbalance', 'materials', 'friction', 'calving') filename = md.miscellaneous.name if len(md.results.TransientSolution) == ( md.timestepping.final_time * 10 / md.settings.output_frequency) + 1:
md = parameterize(md, '../Par/SquareShelf.py') md = setflowequation(md, 'SSA', 'all') md.extrude(3, 1.) md.cluster = generic('name', gethostname(), 'np', 2) md.transient.isthermal = False md.timestepping.time_step = 1. md.settings.output_frequency = 1 md.timestepping.final_time = 2000. #Solve for thinning rate -> -1 * surface mass balance smb = 2. * np.ones((md.mesh.numberofvertices)) md.smb.mass_balance = smb md.basalforcings.groundedice_melting_rate = smb md = solve(md, 'Masstransport') for i in xrange(1, 11): md = solve(md, 'Masstransport') md.smb.mass_balance = md.smb.mass_balance - ( (md.results.MasstransportSolution.Thickness) - md.geometry.thickness) #Set up transient smb = md.smb.mass_balance #tooth= [ [ones(400,1)*(smb') - 10.]' [ones(400,1)*(smb')]' ] tooth = np.hstack((np.tile(smb - 10., (1, 400)), np.tile(smb, (1, 400)))) #smb=[ [ones(399,1)*(smb')]' smb tooth tooth] smb = np.hstack((np.tile(smb, (1, 399)), smb, tooth, tooth)) #md.smb.mass_balance= smb
from socket import gethostname from triangle import * from setmask import * from parameterize import * from setflowequation import * from solve import * md = triangle(model(), '../Exp/Square.exp', 150000.) md = setmask(md, '../Exp/SquareShelf.exp', '') md = parameterize(md, '../Par/SquareSheetShelf.py') md.extrude(3, 2.) md = setflowequation(md, 'SSA', 'all') md.cluster = generic('name', gethostname(), 'np', 3) md.timestepping.time_step = 0 md = solve(md, 'Steadystate') #Fields and tolerances to track changes field_names = [ 'Vx', 'Vy', 'Vz', 'Vel', 'Pressure', 'Temperature', 'BasalforcingsGroundediceMeltingRate' ] field_tolerances = [1e-09, 1e-09, 1e-08, 1e-09, 1e-13, 5e-10, 1e-06] field_values=[\ md.results.SteadystateSolution.Vx,\ md.results.SteadystateSolution.Vy,\ md.results.SteadystateSolution.Vz,\ md.results.SteadystateSolution.Vel,\ md.results.SteadystateSolution.Pressure,\ md.results.SteadystateSolution.Temperature,\ md.results.SteadystateSolution.BasalforcingsGroundediceMeltingRate,\
from solve import * from randTest import * from genTest import * if __name__ == "__main__": #clear the console clear = lambda: os.system('cls') clear() #accept input print("""Enter a method by its number (default method 1): 1: Solve single problem with GUI 2: Benchmarking. Solve every problem with every generation algorithm and SOLMAX 3: Benchmarking. Solve single problem with sets of randomly generated tours\n""" ) method = input() clear() #run either the tests or problem solver if method == "2": genTest() elif method == "3": randTest() else: solve()
from solve import * from gen_data import make_data Ns = [10, 20] points = np.array([(1, 0.5), (2, 2)]) vars = np.array([0.5, 0.1]) classes = np.array([-1, 1]) make_data(Ns, points, vars, classes, out="test") solve("test.npz", out="test.png", plot=False)
def test_nqueens(): assert solve(0, 4, []) == 2 assert solve(0, 8, []) == 92
#!/usr/bin/python import sys from solve import * f = open(sys.argv[1], "r") lines = f.readlines()[1:] # skip first line c = 1 i = 0 while i < len(lines): n, l, h = map(int, lines[i].split(" ")) numbers = map(int, lines[i + 1].split(" ")) s = solve(l, h, numbers) if s == None: print "Case #%s: %s" % (c, "NO") else: print "Case #%s: %s" % (c, s) i += 2 c += 1
seed = 5 counter = 0 K = len(y_coords) * len(var_vals) * len(params) * len(slacks) for k in range(len(params)): anim_files = [""] * len(y_coords) * len(var_vals) for i in range(len(var_vals)): for j in range(len(y_coords)): for c in range(len(slacks)): Ns = [10, 10, 20] points = np.array([(-2, 0), (2, 0), (0, y_coords[j])]) vars = np.array([var_vals[i]] * 3) classes = np.array([1, 1, -1]) make_data(Ns, points, vars, classes, out="test", seed=seed) anim_file = "{}{}.jpg".format(name, counter) title = "Var={:0.3f}, param={}, slack={:0.3f}".format( var_vals[i], params[k], slacks[c]) solve("test.npz", kern_type="poly", kern_param=params[k], out=anim_file, plot=False, title=title, slack=slacks[c]) anim_files[j] = anim_file counter += 1 print("image {}/{}".format(counter, K)) # print("creating animation") # create_anim(anim_files, out="anim_p{}.mp4".format(params[k]), duration=0.4)
#Test Name: PigBalVel2 from model import * from socket import gethostname from triangle import * from setmask import * from parameterize import * from setflowequation import * from solve import * md = triangle(model(), '../Exp/Pig.exp', 20000.) md = setmask(md, '../Exp/PigShelves.exp', '../Exp/PigIslands.exp') md = parameterize(md, '../Par/Pig.py') md.initialization.vx[:] = 0. md.initialization.vy[:] = 0. md = setflowequation(md, 'SSA', 'all') md.cluster = generic('name', gethostname(), 'np', 3) md = solve(md, 'Balancevelocity') # Fields and tolerances to track changes field_names = ['DrivingStressX', 'DrivingStressY', 'Vel'] field_tolerances = [1e-13, 1e-13, 1e-13] field_values=[\ md.results.BalancevelocitySolution.DrivingStressX,\ md.results.BalancevelocitySolution.DrivingStressY,\ md.results.BalancevelocitySolution.Vel,\ ]
# locate other code files sys.path.append("../../") import numpy as np from solve import * from gen_data import make_data from printer import create_anim name = "moving_clusters" y_coords = np.linspace(-3, 3, 20) var_vals = np.linspace(0.1, 0.9, 10) counter = 0 K = len(y_coords)*len(var_vals) for i in range(len(var_vals)): anim_files = [""]*len(y_coords) for j in range(len(y_coords)): Ns = [10, 10, 20] points = np.array([(-2, 0), (2, 0), (0, y_coords[j])]) vars = np.array([var_vals[i]]*3) classes = np.array([1, 1, -1]) make_data(Ns, points, vars, classes, out="test") anim_file = "{}{}.jpg".format(name, counter) solve("test.npz", out=anim_file, plot=False, title="Var: {}".format(var_vals[i])) anim_files[j] = anim_file counter += 1 print("image {}/{}".format(counter, K)) # create_anim(anim_files, out="anim{}.gif".format(i), duration=0.5)
#Define a model md=model() md=triangle(md,'../Exp/Square.exp',100000.) md=setmask(md,'','') md=parameterize(md,'../Par/SquareSheetConstrained.py') #Indicate what you want to compute md.gia.cross_section_shape=1 # for square-edged x-section #Define loading history (see test2001.m for the description) md.timestepping.start_time=2400000 # 2,400 kyr md.timestepping.final_time=2500000 # 2,500 kyr md.geometry.thickness=np.vstack((np.hstack((md.geometry.thickness*0.0, 0.0)), np.hstack((md.geometry.thickness/2.0, 0.1)), np.hstack((md.geometry.thickness, 0.2)), np.hstack((md.geometry.thickness, 1.0)), np.hstack((md.geometry.thickness, md.timestepping.start_time)))).T #Solve for GIA deflection md.cluster=generic('name',gethostname(),'np',3) md=solve(md,'Gia') #Fields and tolerances to track changes field_names =['GiaW','GiadWdt'] field_tolerances=[1e-13,1e-13] field_values =[md.results.GiaSolution.GiaW, md.results.GiaSolution.GiadWdt]
for i in range(0, 450, 50): if mouse_y - i < 50: start_y = i break pygame.draw.line(screen, (0, 0, 0), (start_x, start_y), (start_x, start_y + 50), 3) pygame.draw.line(screen, (0, 0, 0), (start_x, start_y), (start_x + 50, start_y), 3) pygame.draw.line(screen, (0, 0, 0), (start_x + 50, start_y), (start_x + 50, start_y + 50), 3) pygame.draw.line(screen, (0, 0, 0), (start_x, start_y + 50), (start_x + 50, start_y + 50), 3) is_clicked = True if mouse_x < 100 and mouse_y > 450: solve(given) keys = pygame.key.get_pressed() if not given[start_y / 50][start_x / 50]: color = (150, 150, 150) if keys[pygame.K_1]: check(1) number(1, start_x + 25, start_y + 25) board[start_y / 50][start_x / 50] = 1 if keys[pygame.K_2]: check(2) number(2, start_x + 25, start_y + 25) board[start_y / 50][start_x / 50] = 2 if keys[pygame.K_3]:
def test(size, rows, cols, expectedSol): form = reduce_board(size, rows, cols) testSol = solve(form) for i in range(size * size): assert(testSol[1][i] == expectedSol[i])
def test_parse1(self): solve(parse("a", char("b")))
file_content = input_file.read() file_lines = file_content.split('\n') problem_grid = [[] for i in range(len(file_lines))] sqrt_n = int(sqrt(len(file_lines))) for j in range(len(file_lines)): line_values = [(int(value) if value != '-' else None) for value in file_lines[j].split(' ')] for i in range(len(line_values)): problem_grid[int(i / sqrt_n) + int(j / sqrt_n) * sqrt_n].append( line_values[i]) try: solution, best_fitness = solve( problem_grid, population_size=args.population_size, selection_rate=args.selection_rate, max_generations_count=args.max_generations_count, mutation_rate=args.mutation_rate) output_str = "Best fitness value: " + str( best_fitness) + '\n\n' for a, b in same_column_indexes(solution, 0, 0, sqrt_n): row = list( get_cells_from_indexes( solution, same_row_indexes(solution, a, b, sqrt_n))) output_str += " ".join([str(elem) for elem in row]) + '\n' output_str = output_str if args.output_file: with open(args.output_file, "w") as output_file:
def test_parse2(self): solve(parse("a", char("a")))
y_coords = np.linspace(-3, 3, 20) var_vals = np.linspace(0.3, 2, 3) params = np.linspace(0.01, 1, 10) seed = 5 counter = 0 K = len(y_coords) * len(var_vals) * len(params) for k in range(len(params)): anim_files = [""] * len(y_coords) * len(var_vals) for i in range(len(var_vals)): for j in range(len(y_coords)): Ns = [10, 10, 20] points = np.array([(-2, 0), (2, 0), (0, y_coords[j])]) vars = np.array([var_vals[i]] * 3) classes = np.array([1, 1, -1]) make_data(Ns, points, vars, classes, out="test", seed=seed) anim_file = "{}{}.jpg".format(name, counter) title = "Var={:0.3f}, param={}".format(var_vals[i], params[k]) solve("test.npz", kern_type="rbf", kern_param=params[k], out=anim_file, plot=False, title=title) anim_files[j] = anim_file counter += 1 print("image {}/{}".format(counter, K)) # print("creating animation") # create_anim(anim_files, out="anim_p{}.mp4".format(params[k]), duration=0.4)
def test_parse3(self): solve(parse("a", or_(char("b"), char("a"))))
md.stressbalance.spcvy[pos]=0. md.stressbalance.spcvz[pos]=0. #Create MPCs to have periodic boundary conditions posx=np.nonzero(md.mesh.x==0.)[0] posx2=np.nonzero(md.mesh.x==np.max(md.mesh.x))[0] posy=np.nonzero(logical_and.reduce_n(md.mesh.y==0.,md.mesh.x!=0.,md.mesh.x!=np.max(md.mesh.x)))[0] #Don't take the same nodes two times posy2=np.nonzero(logical_and.reduce_n(md.mesh.y==np.max(md.mesh.y),md.mesh.x!=0.,md.mesh.x!=np.max(md.mesh.x)))[0] md.stressbalance.vertex_pairing=np.vstack((np.hstack((posx.reshape(-1,1)+1,posx2.reshape(-1,1)+1)),np.hstack((posy.reshape(-1,1)+1,posy2.reshape(-1,1)+1)))) #Compute the stressbalance md.cluster=generic('name',gethostname(),'np',8) md.verbose=verbose('convergence',True) md=solve(md,'Stressbalance') md.stressbalance.reltol=np.nan md.stressbalance.abstol=np.nan md.stressbalance.vertex_pairing=np.empty((0,2)) #We need one grid on dirichlet: the 4 corners are set to zero md.stressbalance.spcvx=np.nan*np.ones((md.mesh.numberofvertices)) md.stressbalance.spcvy=np.nan*np.ones((md.mesh.numberofvertices)) md.stressbalance.spcvz=np.nan*np.ones((md.mesh.numberofvertices)) pos=np.nonzero(logical_or.reduce_n(md.mesh.y==0.,md.mesh.x==0.,md.mesh.x==np.max(md.mesh.x),md.mesh.y==np.max(md.mesh.y))) #Don't take the same nodes two times md.stressbalance.spcvx[pos]=md.results.StressbalanceSolution.Vx[pos] md.stressbalance.spcvy[pos]=md.results.StressbalanceSolution.Vy[pos] md=setflowequation(md,'FS','all') md=solve(md,'Stressbalance') #Plot the results and save them vx=md.results.StressbalanceSolution.Vx
def test_parse4(self): solve(parse("ab", and_(char("a"), char("b"))))
def test_begin(self): solve(begin(prin(1), prin(2), prin(3)))
def test_parse5(self): solve(parse("ab", begin(char("a"), prin(1), char("b"))))
def test_unify(self): solve(unify(1, 1), bindings)
def test_parse6(self): solve(parse("ab", begin(char("a"), integer(1), char("b"))))
md = triangle(model(), '../Exp/Square.exp', 150000.) md = setmask(md, 'all', '') md = parameterize(md, '../Par/SquareShelfConstrained.py') md.cluster = generic('name', gethostname(), 'np', 1) md.transient.requested_outputs = ['IceVolume', 'TotalSmb'] md.extrude(3, 1.) md = setflowequation(md, 'HO', 'all') md.verbose = verbose('solution', 1) md.settings.recording_frequency = 5 # time steps and resolution md.timestepping.final_time = 8 md = solve(md, 'Transient') md2 = copy.deepcopy(md) md = solve(md, 'Transient', 'restart', 1) #Fields and tolerances to track changes field_names = [ 'Vx1', 'Vy1', 'Vel1', 'TotalSmb1', 'Bed1', 'Surface1', 'Thickness1', 'Volume1', 'Temperature1', 'Pressure1', 'Vx2', 'Vy2', 'Vel2', 'TotalSmb2', 'Bed2', 'Surface2', 'Thickness2', 'Volume2', 'Temperature2', 'Pressure2', 'Vx3', 'Vy3', 'Vel3', 'TotalSmb3', 'Bed3', 'Surface3', 'Thickness3', 'Volume3', 'Temperature3', 'Pressure3' ] field_tolerances=[1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,\ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,\ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,\ 1e-13,1e-13,1e-13,1e-13,1e-13,1e-13,\
def test_succeed(self): solve(succeed)
#Test Name: 79NorthBedSlop3d import numpy as np from model import * from socket import gethostname from triangle import * from setmask import * from parameterize import * from setflowequation import * from solve import * md=triangle(model(),'../Exp/79North.exp',10000.) md=setmask(md,'../Exp/79NorthShelf.exp','') md=parameterize(md,'../Par/79North.py') md.extrude(2,1.) md=setflowequation(md,'SSA','all') md.cluster=generic('name',gethostname(),'np',3) md=solve(md,'BedSlope') #Fields and tolerances to track changes field_names =['BedSlopeX','BedSlopeY'] field_tolerances=[1e-13,1e-13] field_values=[\ md.results.BedSlopeSolution.BedSlopeX,\ md.results.BedSlopeSolution.BedSlopeY,\ ]
def test_fail(self): solve(fail)
from display import display as display from solve import * board = [[7, 8, 0, 4, 0, 0, 1, 2, 0], [6, 0, 0, 0, 7, 5, 0, 0, 9], [0, 0, 0, 6, 0, 1, 0, 7, 8], [0, 0, 7, 0, 4, 0, 2, 6, 0], [0, 0, 1, 0, 5, 0, 9, 3, 0], [9, 0, 4, 0, 6, 0, 0, 0, 5], [0, 7, 0, 3, 0, 0, 0, 1, 2], [1, 2, 0, 0, 0, 7, 4, 0, 0], [0, 4, 9, 2, 0, 6, 0, 0, 7]] # 2-d array that represents the sudoku board display(board) if solve(board): # if the board is solvable print("solved board:") display(board) else: # if the board is unsolvable print("task failed sucessfully")
def test_and1(self): solve(and_(succeed, succeed))
configs = configs.split('\n') for config in configs: if config == '': #empty line continue config = config.split("\n")[0] config_dict = readconfig(case, config) #Also creates the 'instance' attribute config_dict['folder'] = folder print_config(config_dict) #solve(num_solutions,problem_dict,smtdict,num_vars,num_rels,arity,existential,conjuncts,labelconstraint,counting,smt_path) solve(config_dict, problem_dict, smtdict, smt_path) end = time.time() timestr = "The entire config file took " + str(end - start) + " seconds." timefile = open(folder + 'configtime.txt', 'w') timefile.write(timestr) timefile.close() # # print sys.argv # num_vars = int(sys.argv[2]) # num_rels = int(sys.argv[3]) # arity = 2 # existential = sys.argv[4] # conjuncts = sys.argv[5] # labelconstraint = sys.argv[6] # case = sys.argv[1]
def test_and2(self): solve(and_(succeed, fail))
def assert_bad(size, rows, cols): form = reduce_board(size, rows, cols) testSol = solve(form) assert(not testSol[0])
def test_not1(self): solve(not_(fail))
md.hydrology = md.hydrology.initialize(md) md.hydrology.isefficientlayer = 0 md.hydrology.sedimentlimit_flag = 1 md.hydrology.sedimentlimit = 8000.0 md.initialization.sediment_head = np.zeros((md.mesh.numberofvertices)) md.hydrology.spcsediment_head = np.nan * np.ones((md.mesh.numberofvertices)) md.hydrology.spcsediment_head[np.where(md.mesh.y == 0)] = 0.0 md.basalforcings.groundedice_melting_rate = 2.0 * np.ones( (md.mesh.numberofvertices)) md.basalforcings.floatingice_melting_rate = 0.0 * np.ones( (md.mesh.numberofvertices)) md.hydrology.sediment_transmitivity = 3.0 * np.ones((md.mesh.numberofvertices)) md.timestepping.time_step = 0 md.timestepping.final_time = 1.0 md.extrude(3, 1.) md = solve(md, 'Hydrology') #Fields and tolerances to track changes #you can also compare with an analitic solution, but it is exact #only if no limits are applied #analitic=(md.mesh.y.^2-2*md.mesh.y*1.0e6)*(-2.0/(2*md.constants.yts*md.hydrology.sediment_transmitivity)) field_names = ['SedimentWaterHead', 'SedimentHeadResidual'] field_tolerances = [1e-13, 3e-10] field_values = [ md.results.HydrologySolution.SedimentHead, md.results.HydrologySolution.SedimentHeadResidual ]
def test_not2(self): solve(not_(succeed))
#Test Name: 79NorthBalThic2d import numpy as np from model import * from socket import gethostname from triangle import * from setmask import * from parameterize import * from setflowequation import * from solve import * md = triangle(model(), '../Exp/79North.exp', 10000.) md = setmask(md, '../Exp/79NorthShelf.exp', '') md = parameterize(md, '../Par/79North.py') md = setflowequation(md, 'SSA', 'all') md.cluster = generic('name', gethostname(), 'np', 3) md = solve(md, 'Balancethickness') #Fields and tolerances to track changes field_names = ['Thickness'] field_tolerances = [1e-12] field_values=[\ md.results.BalancethicknessSolution.Thickness,\ ]
def test_or1(self): solve(or_(fail, succeed))
#Test Name: PigTherSteaSUPG import numpy as np from model import * from socket import gethostname from triangle import * from setmask import * from parameterize import * from setflowequation import * from solve import * md = triangle(model(), '../Exp/Pig.exp', 30000.) md = setmask(md, '../Exp/PigShelves.exp', '../Exp/PigIslands.exp') md = parameterize(md, '../Par/Pig.py') md.extrude(3, 1.) md = setflowequation(md, 'HO', 'all') md.thermal.stabilization = 2 md.cluster = generic('name', gethostname(), 'np', 3) md.timestepping.time_step = 0 md.thermal.penalty_threshold = 40 md = solve(md, 'Thermal') #Fields and tolerances to track changes field_names = ['Temperature', 'BasalforcingsGroundediceMeltingRate'] field_tolerances = [1e-11, 1e-11] field_values=[\ md.results.ThermalSolution.Temperature,\ md.results.ThermalSolution.BasalforcingsGroundediceMeltingRate,\ ]
def test_or2(self): solve(or_(succeed, succeed))
#Test Name: 79NorthSurfSlop2d import numpy as np from model import * from socket import gethostname from triangle import * from setmask import * from parameterize import * from setflowequation import * from solve import * md = triangle(model(), '../Exp/79North.exp', 10000.) md = setmask(md, '../Exp/79NorthShelf.exp', '') md = parameterize(md, '../Par/79North.py') md = setflowequation(md, 'SSA', 'all') md.cluster = generic('name', gethostname(), 'np', 3) md = solve(md, 'SurfaceSlope') #Fields and tolerances to track changes field_names = ['SurfaceSlopeX', 'SurfaceSlopeY'] field_tolerances = [1e-13, 1e-13] field_values=[\ md.results.SurfaceSlopeSolution.SurfaceSlopeX,\ md.results.SurfaceSlopeSolution.SurfaceSlopeY,\ ]
def test_or3(self): solve(or_(succeed, fail))
#Test Name: SquareShelfConstrainedMasstransp3dAdolcMumps from model import * from socket import gethostname from triangle import * from setmask import * from parameterize import * from setflowequation import * from solve import * md = triangle(model(), '../Exp/Square.exp', 150000.) md = setmask(md, 'all', '') md = parameterize(md, '../Par/SquareShelfConstrained.py') md = setflowequation(md, 'SSA', 'all') md.extrude(5, 3.) md.cluster = generic('name', gethostname(), 'np', 3) md.autodiff.isautodiff = True md = solve(md, 'Masstransport') #Fields and tolerances to track changes field_names = ['Thickness'] field_tolerances = [1e-13] field_values=[\ md.results.MasstransportSolution.Thickness,\ ]
def test_or4(self): solve(or_(prin(1), prin(2)))
md.timestepping.time_step = 1. md.settings.output_frequency = 1 md.timestepping.final_time = 4. #Set up transient smb = np.ones((md.mesh.numberofvertices)) * 3.6 smb = np.vstack((smb, smb * -1.)).T md.smb = SMBmeltcomponents() md.smb.accumulation = np.vstack((smb, [1.5, 3.])) md.smb.evaporation = np.vstack((smb / 2, [1.5, 3.])) md.smb.melt = np.vstack((smb / 2, [1.5, 3.])) md.smb.refreeze = np.vstack((smb, [1.5, 3.])) md.transient.isthermal = False md = solve(md, 'Transient') #Fields and tolerances to track changes field_names = [ 'Vx1', 'Vy1', 'Vel1', 'Pressure1', 'Bed1', 'Surface1', 'Thickness1', 'SmbMassBalance1', 'Vx2', 'Vy2', 'Vel2', 'Pressure2', 'Bed2', 'Surface2', 'Thickness2', 'SmbMassBalance2', 'Vx3', 'Vy3', 'Vel3', 'Pressure3', 'Bed3', 'Surface3', 'Thickness3', 'SmbMassBalance3', 'Vx4', 'Vy4', 'Vel4', 'Pressure4', 'Bed4', 'Surface4', 'Thickness4', 'SmbMassBalance4' ] field_tolerances = [ 1e-09, 1e-09, 1e-09, 1e-10, 1e-10, 1e-10, 1e-10, 1e-10, 1e-09, 1e-09, 1e-09, 1e-10, 1e-10, 1e-10, 1e-10, 1e-10, 1e-09, 1e-09, 1e-09, 1e-10, 1e-10, 1e-10, 1e-10, 1e-10, 1e-09, 1e-09, 1e-09, 1e-10, 1e-10, 1e-10, 1e-10, 1e-10 ]
# 2 . . 5 6 . . . # ''' fp = StringIO.StringIO(board) def readLine(): return fp.readline(); def readBoard(): l = int(readLine()) size = (l, l) map = {} y = 0 while (y<l): line = readLine() x = 0 i = 0 while (x<l): if (line[i].isdigit()): map[(x,y)] = boardPiece(int(line[i])); x+=1 if (line[i] == "."): map[(x,y)] = boardPiece(0); x+=1 i+=1 y+=1 return (map, size) b=readBoard() solve(b)