Commit 5f487878 authored by Thomas Fenz's avatar Thomas Fenz
Browse files

upload files

parent f64cb593
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+229 −0
Original line number Diff line number Diff line
# Created by .ignore support plugin (hsz.mobi)
### Python template
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
#  Usually these files are written by a python script from a template
#  before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
### Windows template
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk
### Linux template
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea*
.idea/*
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/dictionaries
.idea/**/shelf

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/
cmake-build-release/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Gurobi export
gurobi.log
+42 −2
Original line number Diff line number Diff line
# 2019-networking
# Overview 2019-networking

Public repository for reproducibility of our IFIP Networking 2019 paper
 No newline at end of file
This repository contains a simple framework for routing for reconfigurable demand-aware networks.
The code is written in **Python3.6** and requires some few packages (see next section)

The code has been the basis for computational evaluations within the following publication:
**[1]** Thomas Fenz, Klaus-Tycho Foerster, Stefan Schmid, Anaïs Villedieu: **"Efficient Non-Segregated Routing for Reconfigurable Demand-Aware Networks"**. IFIP Networking 2019 Conference.

# Dependencies and Requirements

Python 3.6. Required python libraries: gurobipy, networkx, munkres, matplotlib. 
**Note**: Our source is tested only on Linux (Ubuntu 18.04.1 LTS) and macOs (Mojave 10.14.3).  

# Structure

* The folder **[algorithms/heuristics](algorithms/heuristics/)** contains all implemented heuristic algorithms.
* The folder **[algorithms/ilps](algorithms/ilps/)** contains all different versions of the implemented ilp algorithm.
* The folder **[data_sets](data_sets/)** contains two sets of input data to test the algorithms (static topology, optical topology, demands).

# Code Structure

The code is structured as follows:

 * **run_simple_tests.py** is the main entry point of the program. It fetches the input data from the data sets and executes all implemented algorithm.
 * **data_sets/simple_data_set1.py** contains simple input data (static topology, optical topology, demands)
 * **data_sets/simple_data_set2.py** contains simple input data (static topology, optical topology, demands)
 * **algorithms/heuristics/demand_first_directed.py** contains the implementation of the Demand First (directed) algorithm
 * **algorithms/heuristics/demand_first_undirected.py** contains the implementation of the Demand First (undirected) algorithm
 * **algorithms/heuristics/gain_demand_directed.py** contains the implementation of the Gain Demand (directed) algorithm
 * **algorithms/heuristics/gain_demand_undirected.py** contains the implementation of the Gain Demand (undirected) algorithm
 * **algorithms/heuristics/gain_update_directed.py** contains the implementation of the Gain Update (directed) algorithm
 * **algorithms/heuristics/gain_update_undirected.py** contains the implementation of the Gain Update (undirected) algorithm
 * **algorithms/heuristics/greedy_links_directed.py** contains the implementation of the Greedy Links (directed) algorithm
 * **algorithms/heuristics/greedy_links_undirected.py** contains the implementation of the Greedy Links (undirected) algorithm
 * **algorithms/heuristics/heuristics_helper_directed.py** contains shared methods used by various heuristic algorithms
 * **algorithms/heuristics/heuristics_helper_undirected.py** contains shared methods used by various heuristic algorithms
 * **algorithms/heuristics/segregated_directed.py** contains the implementation of the Segregated (directed) algorithm
 * **algorithms/heuristics/segregated_undirected.py** contains the implementation of the Segregated (undirected) algorithm
 * **algorithms/ilps/ilp_directed.py** contains the implementation of the Ilp (directed) algorithm
 * **algorithms/ilps/ilp_directed_quadratic_constraints.py** contains the implementation of the Ilp (directed) algorithm
 * **algorithms/ilps/ilp_helper.py** contains shared methods used by various ilp algorithms
 * **algorithms/ilps/ilp_undirected.py** contains the implementation Ilp (undirected) algorithm
 * **algorithms/ilps/ilp_undirected_quadratic_constraints.py** contains the implementation of the Ilp (undirected) algorithm

algorithms/__init__.py

0 → 100644
+0 −0

Empty file added.

+0 −0

Empty file added.

+43 −0
Original line number Diff line number Diff line
import networkx as nx
import heuristics_helper_directed as helper


def __demand_first(G, nx_static, D, optical_topology, nN, nR):
    demand_values = []
    demand_pair = []
    for i, j in D:
        demand_pair += [(i, j)]
        demand_values += [D[(i, j)]]
    for k in range(len(D)):
        max_demand = max(demand_values)
        max_index = demand_values.index(max_demand)
        (start, end) = demand_pair[max_index]
        if nx.shortest_path_length(nx_static, start, end, "weight") > nx.shortest_path_length(G, start, end, "weight"):
            helper.update_graph(G, nx_static, nx.shortest_path(G, start, end, "weight"), True, optical_topology, nN, nR)
        del demand_values[max_index]
        del demand_pair[max_index]
    return (nx_static)


def solve(s, o, D):
    ex = None
    nx_full_topology = nx.MultiDiGraph()  # represents all currently possible edges
    nx_static_topology = nx.MultiDiGraph()  # represents static edges and matchings made

    all_arcs_ij = set([(i, j) for _, i, j in o])
    all_arcs_ij.update(s)
    nN = int(max(max(i, j) for i, j in all_arcs_ij) + 1)
    nR = int(max(R for R, _, _ in o) + 1)
    optical_topology = o

    for i, j in s:
        nx_static_topology.add_edge(i, j, weight=s[(i, j)])
        nx_full_topology.add_edge(i, j, key=0, weight=s[(i, j)])
    for r, i, j in o:
        nx_full_topology.add_edge(i, j, key=r + 1, weight=o[(r, i, j)])
    try:
        solution = helper.get_objective(
            __demand_first(nx_full_topology, nx_static_topology, D, optical_topology, nN, nR), D)
    except ex as Exception:
        return False, str(ex), ""
    return True, "", solution
Loading