示例#1
0
 def __init__(self):
     self.val = Validator()
     self.db = DatabaseMaker()
     self.reader = FileReader()
     self.py = PyGal()
     self.converted_file = None
     self.file_count = 1
示例#2
0
def scenario_A(file_in):
    print("Input file: {}".format(file_in))

    global DEBUG
    reader = FileReader(file_in)
    problem = reader.read()

    solver = Solver(problem)
    print("Description:")
    print(solver.description())

    solution = solver.initial_solution()
    # print(solver.initial_solution().print_free())
    # print("-------")
    # print(solver.initial_solution().print_solution())
    # print("here")
    # print("\n".join(str(i) for i in solver.initial_solution().slices))
    # print("here2")
    print("Initial solution score: {}".format(solution.score()))
    if DEBUG:
        solution.print_solution()

    optimized_solution = solver.search(solution, time_limit=60)
    print("Optimized solution score: {}".format(optimized_solution.score()))
    # print("\n".join(str(i) for i in optimized_solution.slices))
    if DEBUG:
        optimized_solution.print_solution()

    trace = solver.get_search_trace()
    if trace is not None:
        print("Trace:")
        print("\n".join([str(x) for x in trace]))
示例#3
0
def scenario_A(file_in, file_out=None):
    print("Input file: {}".format(file_in))

    reader = FileReader(file_in)
    problem = reader.read()

    solver = Pizza(problem)
    print("Description:")
    print(solver.description())

    slices = solver.solve()

    is_valid, result = problem.validate_solution(slices)

    if is_valid:
        print("Solution for problem {} is correct. Score is {}".format(
            file_in, result))
        solution = Solution(problem)
        solution.load_slices(slices)
        if DEBUG:
            solution.print_solution()
        if file_out:
            writer = FileWriter(file_in + ".out")
            writer.write(solution)
    else:
        print("Incorrect solution. Please check the error messages below")
        for msg in result:
            print(msg)
示例#4
0
def main():
    """Main function for commandline call
    """
    # end user version for user_input
    # args = user_input(sys.argv[1:])

    # add your own args = user_input() for testing and debugging so that you
    # don't have to call the script with full command line input

    args = user_input(['Input/Task1/', '-o', 'Output/Task2/'])

    # read files
    reader = FileReader(args.path)
    input_df = reader.read()

    # perform statistical analysis
    stat_ana = analysis.Statistical_Analysis(args.output)
    stat_ana.correlation(input_df['npop.t'])
    stat_ana.eucl_distance(input_df['table.dat'])

    # perfomr numerical analysis
    num_ana = analysis.Numerical_Analysis(args.output)

    # return new df with the desired columns
    df_efield_relevant = num_ana.remove_low_variance(input_df['efield.t'])

    # fft with freq of the df
    df_efield_fft = num_ana.fft_with_freq_analysis(df_efield_relevant, "y")

    # disabled plot to not have it get on my nerves
    num_ana.plot_and_save(df_efield_fft,
                          "freq",
                          "intensitys",
                          "efield_fft_analysis",
                          xlabel="Freq",
                          show_graph=False)

    df_autocorr = num_ana.autocorrelation(input_df["nstate_i.t"], "time")
    num_ana.plot_and_save(df_autocorr,
                          "time",
                          ["autocorr_abs", "autocorr_real", "autocorr_imag"],
                          "nstate_autocorr_analysis",
                          xlabel="time",
                          show_graph=False)

    df_autocorr_fft = num_ana.fft_with_freq_analysis(df_autocorr,
                                                     "autocorr",
                                                     type="complex")

    # adding abs**2 to the dataframe
    df_autocorr_fft["intensitys_squared"] = np.abs(
        df_autocorr_fft["intensitys"].values)**2
    num_ana.plot_and_save(df_autocorr_fft,
                          "freq", ["intensitys", "intensitys_squared"],
                          "nstate_autocorr_fft_analysis",
                          xlabel="Freq",
                          show_graph=True,
                          crop_edge=3)
示例#5
0
def scenario_A(file_in, file_out):
    global DEBUG
    reader = FileReader(file_in)
    problem = reader.read()

    init_solver = InitSolverSilly()
    solution = init_solver.run(problem)
    print("Initial solution score: {}".format(solution.score()))
    if DEBUG:
        solution.print_solution()

    writer = FileWriter(file_out)
    writer.write(solution)
示例#6
0
def scenario_C(file_in, file_out, file_par=None):
    global DEBUG
    reader = FileReader(file_in)
    problem = reader.read()

    init_solver = ParallelInitSolver(InitSolverSillyParameterized,
                                     file_output=file_out)
    solution = init_solver.run(problem, file_par)
    print("Initial solution score: {}".format(solution.score()))
    if DEBUG:
        solution.print_solution()

    writer = FileWriter(file_out)
    writer.write(solution)
示例#7
0
def scenario_A(file_in):
    print("Input file: {}".format(file_in))

    global DEBUG
    reader = FileReader(file_in)
    problem = reader.read()

    solver = Solver(problem)
    print("Description:")
    print(solver.description())

    solution = solver.initial_solution()
    print("Initial solution score: {}".format(solution.score()))
    if DEBUG:
        solution.print_solution()

    optimized_solution = solver.search(solution, time_limit=60)
    print("Optimized solution score: {}".format(optimized_solution.score()))
    if DEBUG:
        optimized_solution.print_solution()

    trace = solver.get_search_trace()
示例#8
0
def scenario_B(file_in, file_out):
    global DEBUG
    reader = FileReader(file_in)
    problem = reader.read()

    init_solver = InitSolverSilly()
    solution = init_solver.run(problem)
    print("Initial solution score: {}".format(solution.score()))
    if DEBUG:
        solution.print_solution()

    optimizer = Tabu(problem,
                     solution,
                     Neighbourhood_ChangeFormats,
                     debug=True)
    optimized_solution = optimizer.run(time_limit=100)

    print("optimized solution score: {}".format(optimized_solution.score()))
    if DEBUG:
        optimized_solution.print_solution()

    writer = FileWriter(file_out)
    writer.write(optimized_solution)
示例#9
0
def plot_specific_heat_ratio_isobaric(filename, plot_cp=True):
    data = FileReader(filename)

    # Plot 1
    fig, ax1 = plt.subplots()
    if plot_cp:
        color = 'b'
    else:
        color = 'k'
    ax1.plot(data.temperature, data.gamma, color, label='Specific Heat Ratio')
    ax1.set_xlabel(data.titles.temperature)
    ax1.set_ylabel(data.titles.gamma)

    if plot_cp:
        # Plot 2
        ax2 = ax1.twinx()
        ax2.plot(data.temperature, data.cp, 'r', label='Cp')
        ax2.set_ylabel(data.titles.cp)
        fig.legend(loc="upper center", bbox_to_anchor=(0.5, 0.9))

    plt.title('Specific heat ratio of water (g) at 6 bar')
    fig.tight_layout()
    plt.show()
示例#10
0
def scenario_D(file_in, file_out, file_par=None):
    global DEBUG
    reader = FileReader(file_in)
    problem = reader.read()

    init_solver = ParallelInitSolver(InitSolverSillyParameterized,
                                     file_output=file_out)
    solution = init_solver.run(problem, file_par)
    print("Initial solution score: {}".format(solution.score()))
    if DEBUG:
        solution.print_solution()

    optimizer = ParallelTabu(problem,
                             solution,
                             Neighbourhood_ChangeFormats,
                             debug=True)
    optimized_solution = optimizer.run(time_limit=1000)

    print("optimized solution score: {}".format(optimized_solution.score()))
    if DEBUG:
        optimized_solution.print_solution()

    writer = FileWriter(file_out)
    writer.write(solution)
示例#11
0
 def __init__(self, filename):
     self.filename = FileReader(filename)
 def __init__(self):
     self.data = FileReader().readFile("district.csv")
示例#13
0
 def __init__(self):
     self.data = FileReader().readFile("trans.csv")
 def __init__(self):
     self.data = FileReader().readFile("client.csv")
示例#15
0
 def __init__(self):
     self.data = FileReader().readFile("loan.csv")
示例#16
0
import math
import time
from flask import Flask, request, jsonify
from flask_cors import CORS
from reader import FileReader, Bolder

app = Flask(__name__)
CORS(app)
start_reading = time.time()
reader = FileReader('./data/IR-F19-Project01-Input.xlsx', True,
                    './matches.json', './exceptions.txt')
# reader = FileReader('./data/IR-F19-Project01-Input-2k.xlsx', True, './matches.json', './exceptions.txt')
# reader = FileReader('./data/IR-F19-Project02-14k.csv', False, './matches.json', './exceptions.txt')
end_reading = time.time()
print("Reading Files:", end_reading - start_reading, "secs")
bolder = Bolder()


@app.route('/')
def query():
    q = request.args.get('q')
    start_searching = time.time()
    print("Query:", q)
    docs, query_tokens = reader.search(q, 50)
    docs, query_tokens = list(docs), list(query_tokens)
    print("Results:", len(docs))
    items = int(request.args.get('items', 10))
    print("Items:", items)
    pages = math.ceil(len(docs) / items)
    print("Pages:", pages)
    page = int(request.args.get('page', 0))
示例#17
0
from reader import FileReader, UrlReader
from sma import SMA, SMAPlt

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Лабораторная №4')

    parser.add_argument('--paths=',
                        help='Список адресов через запятую',
                        required=True,
                        dest="paths")
    parser.add_argument('--frame=',
                        help='Размер окна',
                        required=True,
                        dest="frame")
    args = parser.parse_args()
    paths = [item for item in args.paths.split(',')]

    if len(paths) < 25:
        print('Кол-во данных меньше 25')
        exit()

    sma = SMA()
    print('Загрузка данных...')
    for path in paths:
        reader = FileReader() if FileReader.path_is_file(path) else UrlReader()
        sma.read_data(reader, path)

    sma.frame = args.frame

    SMAPlt.draw(*sma.calculate_sma())
示例#18
0
 def __init__(self):
     self.data = FileReader().readFile("account.csv")