Пример #1
0
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])
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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])
Пример #5
0
 def setUp(self):
     self.testArray = problem2D.problemMatrix
     self.testProblem = peak.createProblem(self.testArray)
Пример #6
0
def main():
    testArray = problem2D.problemMatrix
    testProblem = peak.createProblem(testArray)
    testPeak = algorithm4(testProblem)
Пример #7
0
 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))
Пример #8
0
# -*- 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))