diff --git a/main.py b/main.py index 54d8a70c5d8647bdd996b82999250b2d9ba87135..da88ec9d7a6f7c113e7c1cb3922a0d10795c00ae 100644 --- a/main.py +++ b/main.py @@ -21,7 +21,7 @@ from resources.simplex import Simplex logger = init_logging.get_logger(__name__) -def create_network_graph(small_flow=True): +def create_network_graph(small_flow=False): """ Creates new instance of network problem, using custom "Graph Library" Network Flow class. :return: A "Network Flow Graph" class instance of the problem to solve. @@ -307,30 +307,22 @@ def simplex(): # Set constraint row values. for incoming_edge in incoming_edges: edge_index = all_graph_edges.index(incoming_edge) - constraint_row[edge_index] = incoming_edge.get_weight() + constraint_row[edge_index] = 1 + for outgoing_edge in outgoing_edges: + edge_index = all_graph_edges.index(outgoing_edge) + constraint_row[edge_index] = -1 constraints.append(constraint_row) # Set constant values. - total_capacity_out = 0 - for outgoing_edge in outgoing_edges: - total_capacity_out += outgoing_edge.get_capacity() - constants.append(total_capacity_out) + # total_capacity_out = 0 + # for outgoing_edge in outgoing_edges: + # total_capacity_out += outgoing_edge.get_capacity() + # constants.append(total_capacity_out) + constants.append(0) logger.info('obj: {0}'.format(objective)) logger.info('constraints: {0}'.format(constraints)) - - # # Loop through one last time and create basic variable columns. - # for edge_index in range(len(all_graph_edges)): - # for row_index in range(len(constraints)): - # # Check if edge and row index are the same. - # if edge_index == row_index: - # # Set as basic var value. - # constraints[row_index].append(1) - # else: - # # Set as not basic var value. - # constraints[row_index].append(0) - # - # objective.append(0) + logger.info('constants: {0}'.format(constants)) # Pass values into simplex and attempt to solve. simplex = Simplex()