GithubHelp home page GithubHelp logo

jkomyno / algorithms-hw3 Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 1.0 1.09 MB

License: MIT License

C++ 19.66% Makefile 1.19% Python 27.50% Shell 0.94% TeX 50.70%
randomized-algorithms minimum-cut karger karger-stein

algorithms-hw3's Introduction

Algorithms-HW3

Build Status

Minimum Cut with Karger algorithm.

An hands-on experience about algorithms over graph and graph theory with the focus on efficiency.

Usage

The repositores comes with some utility commands that allows you to compile, test and bench owr algorithms. We use make to automatize this process.

Available commands

  • make all, to compile all the algorithm sources in this project.
  • make ALG, where ALG is one of KargerMinCut, KargerMinCutTimeout, KargerSteinMinCut to compile given algorithm sources.
  • make clear, to clean up the working directory.

Within the Makefile we provieded some variables to modify our pipeline. In particular you can use your own compiler rewriting the CXX flag. Other variables can be modified, for example CXXFLAGS, OUT_DIR and EXT.

Example

make CXX="g++" CXXFLAGS="-O3 -std=c++17 -I Shared" OUT_DIR="build" EXT="exe" all

Scripts

We created some bash scripts in order to automatize recurrent tasks like benchmarking. You can take a look at the script run.sh, runall.sh and process.py for further informations.

In particular,

  • run.sh executes a program with some options and saves its output,
  • runall.sh, executes all listed programs using run.sh,
  • process.py, processes a program output and returns it in a machine readable format.

Report

We created also a report with a not-so-short description of owr work. You can find it in the directory report. The report is a LaTeX project subdivided for readability purposes in some directories like chapters and images. All starts in the main.tex file.

In order to compile sources, navigate to report directory and

  • if you have pdflatex installed, run make pdf,
  • if you have docker installed, run make pdf2.

Note: we didn't tested the doker build, there could be errors.

Project Structure

The project is structured as a unique Visual Studio solution containing multiple subprojects, one for every implemented algorithm. The code for each project is stored in a folder with the same name of the related algorithm.

These projects are:

The shared data structures and utils are stored in the Shared folder.

The project comes with some extra folders:

  • benchmark: it contains CSV benchmarks of the algorithm as well as the script used to analyze them (analysis.py);
  • datasets: it contains the input data for the graphs given by our professor;

Related Projects

  • algorithms-hw2 the previous homework on Travelling Salesman Problem with Held & Karp, approximated and heuristic algorithms.
  • algorithms-hw1 the previous homework on MST algorithms.

Authors

Bryan Lucchetta

Luca Parolari

Alberto Schiabel

License

This project is MIT licensed. See LICENSE file.

algorithms-hw3's People

Contributors

jkomyno avatar lparolari avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

lparolari

algorithms-hw3's Issues

Plot graphs using a Python3 script

Generale

  • variazione dei tempi di calcolo al variare del numero di vertici nel grafo senza timeout
  • variazione dei tempi di calcolo al variare del numero di vertici nel grafo con timeout
  • confronto tra discovery time e tempo di esecuzione complessivo per ognuno dei grafi nel dataset

Confronto tra implementazioni

  • variazione dei tempi di calcolo per 4 grafi di grandi dimensioni tra KargerMinCut (senza timeout) e KargerSteinMinCut
  • variazione dei tempi di calcolo per 4 grafi di grandi dimensioni tra KargerMinCut (con timeout) e KargerSteinMinCut

Dataset di input da usare:

  • input_random_25_125.txt
  • input_random_29_150.txt
  • input_random_35_175.txt
  • input_random_40_200.txt

Add discussion about program execution statistics in MinCutKarger

In MinCutKarger, we have the following statistics:

  • the longest discovery time takes is seconds, corresponding to the graph input_random_38_200.txt;
  • the longest full_contraction execution takes 9 milliseconds, corresponding to the graph input_random_40_200.txt;
  • the average running time is 176 seconds;
  • the average discovery_time / program_time ratio is 0,142401742 when no timeout is used;
  • the maximum discovery_time / program_time ratio is 0,897164825 when no timeout is used, corresponding to the graph input_random_1_6.txt.
  • the second-highest discovery_time / program_time ratio is 0.833009709 when no timeout is used, corresponding to the graph input_random_4_6.txt

Complete TODOs in section "Performance Analysis"

  • fix unità di misura nel grafico "Confronto del running time rispetto al numero di nodi per Karger e Karger con Timeout"
  • il grafico "Confronto tra il tempo di esecuzione per discovery time e runtime rispetto al numero di nodi" deve avere la scala in secondi
  • mostrare il confronto tra iterazione del discovery time e numero di iterazioni k stimate
  • mostrare la tabella dei tempi di esecuzione sia di KargerMinCut che di KargerMinCutTimeout, con colonne istanza, nodi, discovery time, program time. Le righe devono essere ordinate per numero crescente di nodi e istanza
  • rinominare KargerTimeout in KargerMinCutTimeout
  • mostrare la tabella di KargerMinCutTimeout, con colonne istanza, nodi, soluzione attesa, min-cut. Le righe devono essere ordinate per numero crescente di nodi istanza
  • rinominare legenda del grafico "Confronto discovery iteration stimata vs ottenuta rispetto al numero di nodi per
    KargerMinCut" da Estimated a K (o upper bound) e non calcolarla a mano, utilizzare la k del benchmark
  • rinominare program time in runtime nel report
  • sul grafico "Confronto tra il tempo di esecuzione di full_contraction e la sua complessità asintotica
    rispetto al numero di nodi" scrivere n^2 nella legenda dove c'è asintotico e mettere limite inferiore al logaritmo (linea blu)
  • statistiche full contraction tabella in appendice

Add timeout on KargerMinCut

In KargerMinCut, the average complete execution of the algorithm takes 146 seconds (2.5 minutes), but the longest execution takes 918 seconds (15 minutes).
The longest discovery time, however, takes 45 seconds.

We can thus set a maximum execution time to 120 seconds.

We can re-use the same timeout class used for homework 2.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.