This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import geopandas as gpd | |
| import matplotlib.pyplot as plt | |
| # Import all roads NL | |
| map_df = gpd.read_file('roads.shp') | |
| # Show data format | |
| map_df.head() | |
| # Set image properties | |
| fig, ax = plt.subplots(1, figsize=(10,14)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from PIL import Image | |
| # Load created images; for example 4 | |
| amsterdam = Image.open('Amsterdam.png') | |
| hague = Image.open('The_Hague.png') | |
| rotterdam = Image.open('Rotterdam.png') | |
| utrecht = Image.open('Utrecht.png') | |
| # Retrieve width and height original images | |
| width = amsterdam.size[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from skimage import io | |
| import skimage.color as color | |
| import skimage.segmentation as seg | |
| # Read the image you want to process | |
| image = io.imread('image.png') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pulp as pl | |
| # Define PuLP model | |
| model = pl.LpProblem('TSP', pl.LpMinimize) | |
| # Define binary variables | |
| x = pl.LpVariable.dicts('x', ((i, j) for i in range(n_perm) for j in range(n_perm)), cat = 'Binary') | |
| # Set the objective function | |
| model += pl.lpSum(cost_dict[permutations[i], permutations[j]] * x[i, j] for i in range(n_perm) for j in range(n_perm)) |