diff --git a/docs/source/mods/line-optimization.rst b/docs/source/mods/line-optimization.rst index bc78e30c..7a1bc3cd 100644 --- a/docs/source/mods/line-optimization.rst +++ b/docs/source/mods/line-optimization.rst @@ -157,13 +157,13 @@ An example of the inputs with the respective requirements is shown below. 2 1 3 0.006 240 3 3 1 0.006 240 >>> line_data.head(4) - linename capacity fixCost operatingCost + linename capacity fix_cost operating_cost 0 new7_B 600 15 3 1 new15_B 600 15 2 2 new23_B 600 15 6 3 new31_B 600 15 6 >>> linepath_data.head(4) - linename edgeSource edgeTarget + linename edge_source edge_target 0 new7_B 1 2 1 new7_B 2 6 2 new7_B 6 8 @@ -183,7 +183,7 @@ An example of the inputs with the respective requirements is shown below. the property length in the edge data. Also, ``posx`` and ``posy`` in the ``node_data`` is not used for computation. But it can be used to visualize the network as done below. - It is important that all data is consistant. For example, ``edgeSource``, ``edgeTarget`` + It is important that all data is consistant. For example, ``edge_source``, ``edge_target`` in the ``linepath_data`` must correspond to a ``number`` in the node_data. The same holds for ``source`` and ``target`` in ``edge_data`` and ``demand_data``. In the code it is checked that all tables provide the relevant columns. diff --git a/src/gurobi_optimods/data/graphs/siouxfalls_linepaths.csv b/src/gurobi_optimods/data/graphs/siouxfalls_linepaths.csv index 20af1953..13c1f534 100644 --- a/src/gurobi_optimods/data/graphs/siouxfalls_linepaths.csv +++ b/src/gurobi_optimods/data/graphs/siouxfalls_linepaths.csv @@ -1,4 +1,4 @@ -linename,edgeSource,edgeTarget +linename,edge_source,edge_target new7_B,1,2 new7_B,2,6 new7_B,6,8 diff --git a/src/gurobi_optimods/data/graphs/siouxfalls_lines.csv b/src/gurobi_optimods/data/graphs/siouxfalls_lines.csv index 3ceff361..47c24480 100644 --- a/src/gurobi_optimods/data/graphs/siouxfalls_lines.csv +++ b/src/gurobi_optimods/data/graphs/siouxfalls_lines.csv @@ -1,4 +1,4 @@ -linename,capacity,fixCost,operatingCost +linename,capacity,fix_cost,operating_cost new7_B,600,15,3 new15_B,600,15,2 new23_B,600,15,6 diff --git a/src/gurobi_optimods/line_optimization.py b/src/gurobi_optimods/line_optimization.py index d6c69e8e..a27da731 100644 --- a/src/gurobi_optimods/line_optimization.py +++ b/src/gurobi_optimods/line_optimization.py @@ -51,10 +51,10 @@ def line_optimization( It must include "source", "target", and "demand". The demand value must be non-negative. line_data : DataFrame DataFrame with general line information. - It must include "linename", "capacity", "fixCost", and "operatingCost". + It must include "linename", "capacity", "fix_cost", and "operating_cost". linepath_data : DataFrame DataFrame with information on the line routes/paths. - It must include "linename", "edgeSource", and "edgeTarget". + It must include "linename", "edge_source", and "edge_target". frequency: List List with possible frequencies: How often the line can be operated in the considered time horizon. @@ -85,20 +85,20 @@ def line_optimization( if "capacity" not in line_data.columns: logger.info("column capacity not present in line_data") missing_data = True - if "fixCost" not in line_data.columns: - logger.info("column fixCost not present in line_data") + if "fix_cost" not in line_data.columns: + logger.info("column fix_cost not present in line_data") missing_data = True - if "operatingCost" not in line_data.columns: - logger.info("column operatingCost not present in line_data") + if "operating_cost" not in line_data.columns: + logger.info("column operating_cost not present in line_data") missing_data = True if "linename" not in linepath_data.columns: logger.info("column linename not present in linepath_data") missing_data = True - if "edgeSource" not in linepath_data.columns: - logger.info("column edgeSource not present in linepath_data") + if "edge_source" not in linepath_data.columns: + logger.info("column edge_source not present in linepath_data") missing_data = True - if "edgeTarget" not in linepath_data.columns: - logger.info("column edgeTarget not present in linepath_data") + if "edge_target" not in linepath_data.columns: + logger.info("column edge_target not present in linepath_data") missing_data = True if "source" not in demand_data.columns: logger.info("column source not present in demand_data") @@ -139,7 +139,7 @@ def line_optimization( linepaths = ( linepath_data.set_index("linename") .groupby(["linename"]) - .apply(lambda x: [(k, v) for k, v in zip(x["edgeSource"], x["edgeTarget"])]) + .apply(lambda x: [(k, v) for k, v in zip(x["edge_source"], x["edge_target"])]) ) demands = demand_data.set_index(["source", "target"]).to_dict()["demand"] @@ -208,7 +208,7 @@ def all_shortest_paths( for f in frequencies: x[l, f] = model.addVar( vtype=gp.GRB.BINARY, - obj=f * lines[l]["operatingCost"] + lines[l]["fixCost"], + obj=f * lines[l]["operating_cost"] + lines[l]["fix_cost"], name=str(l) + str(f), ) @@ -304,7 +304,7 @@ def allow_all_paths( for f in frequencies: x[l, f] = model.addVar(vtype=gp.GRB.BINARY, name=str(l) + str(f)) obj_cost += x[l, f] * ( - f * lines[l]["operatingCost"] + lines[l]["fixCost"] + f * lines[l]["operating_cost"] + lines[l]["fix_cost"] ) logger.info( @@ -446,7 +446,7 @@ def plot_lineplan( The frame must include "source", "target", and "time" linepath_data : DataFrame DataFrame with information on the line routes/paths. - It must include "linename", "edgeSource", and "edgeTarget". + It must include "linename", "edge_source", and "edge_target". line_plan: List A solution of the line optimization, i.e., a list with linenames and associated frequencies. @@ -467,7 +467,7 @@ def plot_lineplan( linepaths = ( linepath_data.set_index("linename") .groupby(["linename"]) - .apply(lambda x: [(k, v) for k, v in zip(x["edgeSource"], x["edgeTarget"])]) + .apply(lambda x: [(k, v) for k, v in zip(x["edge_source"], x["edge_target"])]) ) G = nx.from_pandas_edgelist(edge_data.reset_index(), create_using=nx.Graph()) for number, row in node_data.set_index("number").iterrows(): diff --git a/tests/test_line_optimization.py b/tests/test_line_optimization.py index 9a4b64b2..54986084 100644 --- a/tests/test_line_optimization.py +++ b/tests/test_line_optimization.py @@ -55,14 +55,14 @@ """ lines = """ -linename,capacity,fixCost,operatingCost +linename,capacity,fix_cost,operating_cost L1,20,9,4 L2,20,9,2 L3,20,9,3 """ linepath = """ -linename,edgeSource,edgeTarget +linename,edge_source,edge_target L1,0,1 L1,1,3 L1,3,4