# -*- coding: utf-8 -*- """ Created on Fri Nov 18 13:38:33 2022 @author: Stephan Bogs (RWTH Aachen, Chair of Operations Management) """ import geopandas as gpd import matplotlib.pyplot as plt def plot_shares(transport, production): # Pie chart, where the slices will be ordered and plotted counter-clockwise: labels = 'Transport', 'Produktion' sizes = [transport, production] fig, ax = plt.subplots() fig.set_dpi(100) ax.pie(sizes, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90) ax.axis('equal') plt.show() fig.savefig('pie_chart.png') def plot_totals_bar(transport, production): fig, ax = plt.subplots() labels = ['Transport', 'Fixed'] counts = [transport, production] ax.bar(labels, counts) fig.set_dpi(100) plt.show() fig.savefig('totals.png') production = [('Krefeld',51.33489008436512, 6.568047013473666), ('Herne',51.53771045684371, 7.194962256766569), ('Paderborn',51.71909942364076, 8.75057976047261)] sinks = [('Koeln',50.93386518777527, 6.958973923969869), ('Bonn',50.740625840775465, 7.0952987924814), ('Duisburg',51.43082091590227, 6.76912922060523), ('Muenster',51.96498607848209, 7.617203294554034), ('Unna',51.537604178977716, 7.690509013834595), ('Bielefeld',52.02833269735831, 8.527475896723134)] def plot_potential_modules(fig, ax): x_values = [value[2] for value in production] y_values = [value[1] for value in production] ax.scatter(x_values, y_values, c="y", label="Produktion") def plot_sinks(fig, ax): x_values = [value[2] for value in sinks] y_values = [value[1] for value in sinks] ax.scatter(x_values, y_values, c="r", label="Kunden") def plot_map(): fp = "landkreise.geojson" data_nrw = gpd.read_file(fp) fig, ax = plt.subplots() data_nrw.plot(ax=ax, facecolor="none", edgecolor="black") def plot_problem(): fp = "landkreise.geojson" data_nrw = gpd.read_file(fp) fig, ax = plt.subplots() # Skalierung des Bildes scale = 1.5 Size = fig.get_size_inches() fig.set_size_inches(Size[0]*scale, Size[1]*scale, forward=True) # Anpassung der Auflösug fig.set_dpi(100) # Plotten der Karte und aller potenziellen Fabriken und Abnahmezenter data_nrw.plot(ax=ax, facecolor="none", edgecolor="black") plot_potential_modules(fig, ax) plot_sinks(fig,ax) # Positionierung der Legende box = ax.get_position() ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) fig.savefig('problem.png') def plot_solution(x): fp = "landkreise.geojson" data_nrw = gpd.read_file(fp) fig, ax = plt.subplots() # Skalierung des Bildes scale = 2 Size = fig.get_size_inches() fig.set_size_inches(Size[0]*scale, Size[1]*scale, forward=True) # Anpassung der Auflösug fig.set_dpi(100) # Plotten der Karte und aller potenziellen Fabriken und Abnahmezenter data_nrw.plot(ax=ax, facecolor="none", edgecolor="black") plot_potential_modules(fig, ax) plot_sinks(fig,ax) # Plotten der Ergebnisse. Eine Verbindung wenn von Fabrik i zu Abnahme j # geliefert wird for i in range(len(production)): for j in range(len(sinks)): if(x[i, j]. x > 0.001): ax.plot([production[i][2], sinks[j][2]], [production[i][1], sinks[j][1]], c='k') fig.savefig('solution.png')