Exemple #1
0
def should_initialize_and_reconstuct():
    with open('simplexTests/dict1') as inp, open('simplexTests/dict1.initialized') as out: 
        dictionary, basic_vars, non_basic_vars = initialize_and_reconstruct(*pivot.make_dictionary(inp))
        expected_dict, expected_basic, expected_non_basic = pivot.make_dictionary(out)
        assert set(basic_vars) == set(expected_basic)
        assert set(non_basic_vars) == set(expected_non_basic)
        assert all(abs(dictionary[:, 0] - expected_dict[:, 0]) < 0.0001)
        print(dictionary, non_basic_vars)
        print(expected_dict, expected_non_basic)
        for v in non_basic_vars:
            col = dictionary[:, np.r_[False, non_basic_vars == v]]
            expected_col = expected_dict[:, np.r_[False, expected_non_basic == v]]
            for bv in basic_vars:
                print (col[bv == basic_vars], expected_col[bv == expected_basic])
                assert all(abs(col[bv == basic_vars] - expected_col[bv == expected_basic]) < 0.0001)
            assert all(abs(col[len(basic_vars)] - expected_col[len(basic_vars)]) < 0.0001)
Exemple #2
0
def should_initialize_and_reconstuct():
    with open('simplexTests/dict1') as inp, open('simplexTests/dict1.initialized') as out: 
        dictionary, basic_vars, non_basic_vars = initialize_and_reconstruct(*pivot.make_dictionary(inp))
        expected_dict, expected_basic, expected_non_basic = pivot.make_dictionary(out)
        assert set(basic_vars) == set(expected_basic)
        assert set(non_basic_vars) == set(expected_non_basic)
        assert all(abs(dictionary[:, 0] - expected_dict[:, 0]) < 0.0001)
        print(dictionary, non_basic_vars)
        print(expected_dict, expected_non_basic)
        for v in non_basic_vars:
            col = dictionary[:, np.r_[False, non_basic_vars == v]]
            expected_col = expected_dict[:, np.r_[False, expected_non_basic == v]]
            for bv in basic_vars:
                print (col[bv == basic_vars], expected_col[bv == expected_basic])
                assert all(abs(col[bv == basic_vars] - expected_col[bv == expected_basic]) < 0.0001)
            assert all(abs(col[len(basic_vars)] - expected_col[len(basic_vars)]) < 0.0001)
                
Exemple #3
0
def optimize_input(file_path):
    return optimize(*pivot.make_dictionary(file_path))
Exemple #4
0
def simplex_input(file_path):
    return simplex_optimal_values(*make_dictionary(file_path))
Exemple #5
0
def simplex_input(file_path):
    return simplex_optimal_values(*make_dictionary(file_path))
def solve_ilp_input(file_path):
    return solve_ilp(*make_dictionary(file_path))
def solve_ilp_input_and_print(file_path):
    dictionary, basic_vars, non_basic_vars = make_dictionary(file_path)
    print(collect_result(*solve_ilp(dictionary, basic_vars, non_basic_vars), original_non_basic = non_basic_vars))
Exemple #8
0
def initialize_input(file_path):
    dictionary, basic_vars, non_basic_vars = pivot.make_dictionary(file_path)
    return initialize(dictionary, basic_vars, non_basic_vars)
Exemple #9
0
def optimize_input(file_path):
    return optimize(*pivot.make_dictionary(file_path))