def loadProblem(file = "problem.py", variable = "problemMatrix"): """ Loads a matrix from a python file, and constructs a PeakProblem from it. """ namespace = dict() with open(file) as handle: exec(handle.read(), namespace) return peak.createProblem(namespace[variable])
def loadProblem(file, variable = "problemList"): """ Loads a 1D peak problem from a python file, and constructs a PeakProblem from it. """ namespace = dict() with open(file) as handle: exec(handle.read(), namespace) matrix = convertFrom1D(namespace[variable]) return peak.createProblem(matrix)
def loadProblem(file, variable="problemList"): """ Loads a 1D peak problem from a python file, and constructs a PeakProblem from it. """ namespace = dict() with open(file) as handle: exec(handle.read(), namespace) matrix = convertFrom1D(namespace[variable]) return peak.createProblem(matrix)
def loadProblem(file='problem.py', variable='problemMatrix'): """ loads a matrix from a python file, and constructs a PeakProblem from it :param file: :param variable: :return: """ namespace = dict() with open(file) as handle: exec(handle.read(), namespace) return peak.createProblem(namespace[variable])
def setUp(self): self.testArray = problem2D.problemMatrix self.testProblem = peak.createProblem(self.testArray)
def main(): testArray = problem2D.problemMatrix testProblem = peak.createProblem(testArray) testPeak = algorithm4(testProblem)
def test_Algorithm1(self): for testNumber in range(10000): testArray = generate.randomProblem(10, 10, 1000) testProblem = peak.createProblem(testArray) testPeak = algorithms.algorithm1(testProblem) self.assertTrue(testProblem.isPeak(testPeak))
# -*- coding: utf-8 -*- """ Created on Tue Dec 29 19:10:30 2020 @author: LH """ import algorithms import peak array = [] with open("array.txt", "r") as f: for line in f: line = line.strip().split(" ") row = list(map(int, line)) array.append(row) print(array) problem = peak.createProblem(array) print(algorithms.algorithm3(problem))