Skip to content

Instantly share code, notes, and snippets.

Avatar
🚲

Dirk Schumacher dirkschumacher

🚲
View GitHub Profile
@dirkschumacher
dirkschumacher / gist:39b47a50f39e52deacf6
Last active Aug 29, 2015
Donations to German parties
View gist:39b47a50f39e52deacf6
= Donations to German parties
data from here: https://github.com/pudo/kompromatron
== Sample Data Set
//setup
[source,cypher]
----
LOAD CSV WITH HEADERS FROM "https://raw.githubusercontent.com/pudo/kompromatron/master/data/spenden.csv" AS data
WITH data SKIP 0 LIMIT 375
MERGE (p:Party { name: data.partei_name, acronym: data.partei_acronym})
View gist:c0c1d78c721aa4fe2adc
= The news reads us data in Neo4J
Data by: http://newsreadsus.okfn.de/
== Intro
Interesting data created by http://newsreadsus.okfn.de/.
I converted the data from the links.json file and converted it into two simple csv files.
//setup
[source,cypher]
----
LOAD CSV FROM "https://dl.dropboxusercontent.com/s/riz5hp32mz0jzed/sites.csv?dl=1" AS csvline
@dirkschumacher
dirkschumacher / bvg.R
Last active Jul 29, 2016
Query BVG billing data from gmail with R
View bvg.R
# Use this code if you use the official BVG Berlin app
# I only tested it with credit card billing
# The BVG sends you an email for every purchase you make.
# The following code tries to find all those mails and analyzes them.
library(gmailr)
library(purrr)
library(stringr)
library(lubridate)
View keybase.md

Keybase proof

I hereby claim:

  • I am dirkschumacher on github.
  • I am dirks (https://keybase.io/dirks) on keybase.
  • I have a public key ASDroBuw_-Dy6s_YoGdf-7cyfLipgEXNflEyoE27_cc14Ao

To claim this, I am signing this object:

@dirkschumacher
dirkschumacher / 20170509_bug_roi.R
Created May 9, 2017
Bounds on binary variables seem to be ignored in ROI (ROI_0.2-1)
View 20170509_bug_roi.R
# Bug report
# It seems variable bounds are ignored when using binary variables "B".
# It works as expected if variables of type "I" are used
library(ROI)
library(ROI.plugin.glpk)
# max: x1 + x2 + x3 + x4
# s.t. x1 + x2 + x3 + x4 <= 4
View disease_video.R
# LICENSE MIT
# Data from RKI with special Terms
library(dplyr)
library(readr)
library(tidyr)
# go to https://survstat.rki.de/Content/Query/Create.aspx
# Selected calendar weeks for rows and diseases for columns.
# had to manually edit, because not a valid csv
View 4-color-berlin.R
# based on a article from here https://dirkschumacher.github.io/ompr/articles/problem-graph-coloring.html
library(maptools)
library(dplyr)
# CC by
# license here https://github.com/berlinermorgenpost/Berlin-Geodaten
map_data <- rgdal::readOGR("https://github.com/berlinermorgenpost/Berlin-Geodaten/raw/master/berlin_bezirke.geojson", "OGRGeoJSON")
# this gives as an adjancy list
View ompr-benchmark.R
# based on the formulation from here
# http://wwwhome.math.utwente.nl/~uetzm/do/IP-FKS.pdf
library(magrittr)
# devtools::install_github("dirkschumacher/ompr@milp")
library(ompr)
max_colors <- 10
n <- 100
# variables n * max_colors
View ompr_milp.md

This vignettes discribes the modelling techniques available in ompr to make your life easier when developing a mixed integer programming model.

A MILP Model

You can think of a MIP Model as a big constraint maxtrix and a set of vectors. But you can also think of it as a set of decision variables, an objective function and a number of constraints as equations/inequalities. ompr implements the latter approach.

View 4-color-world.R
# based on a article from here https://dirkschumacher.github.io/ompr/articles/problem-graph-coloring.html
library(maptools)
library(dplyr)
# devtools::install_github("dirkschumacher/ompr@milp")
# CC by
map_data <- rgdal::readOGR("https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson/ne_50m_admin_0_countries.geojson", "OGRGeoJSON")
You can’t perform that action at this time.