Skip to content

Instantly share code, notes, and snippets.

View abeham's full-sized avatar
👨‍👩‍👦‍👦

Andreas Beham abeham

👨‍👩‍👦‍👦
View GitHub Profile
@abeham
abeham / GECCO 2017 Data
Last active April 24, 2023 13:00
GECCO 2017 Data on Algorithm Selection for the quadratic assignment problem QAP
Beham, A., Affenzeller, M., & Wagner, S. (2017). Instance-based algorithm selection on quadratic assignment problem landscapes. In GECCO 2017 - Proceedings of the Genetic and Evolutionary Computation Conference Companion (pp. 1471-1478). (GECCO 2017 - Proceedings of the Genetic and Evolutionary Computation Conference Companion). ACM Sigevo. https://doi.org/10.1145/3067695.3082513
@inproceedings{10.1145/3067695.3082513,
author = {Beham, Andreas and Affenzeller, Michael and Wagner, Stefan},
title = {Instance-Based Algorithm Selection on Quadratic Assignment Problem Landscapes},
year = {2017},
isbn = {9781450349390},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3067695.3082513},
% Use this editor as a MiniZinc scratch book
array[1..3] of var 0..9: code;
% count(code, X, c) says X must be part of code c times
% count_leq(code, X, c) says X must be part of code at least c times
% Either 6 is correct and there isn't 8 nor 2 or ...
constraint (code[1] == 6 /\ count(code, 8, 0) /\ count(code, 2, 0))
\/ (count(code, 6, 0) /\ code[2] == 8 /\ count(code, 2, 0))
\/ (count(code, 6, 0) /\ count(code, 8, 0) /\ code[3] == 2);
include "globals.mzn";
int: TOTAL = 49;
array[1..3,1..3] of var 1..TOTAL-3: x;
constraint x[2,2] = 21;
constraint alldifferent([x[i,j] | i in 1..3, j in 1..3]);
constraint forall(i in 1..3)(sum(j in 1..3)(x[i,j]) = TOTAL);
constraint forall(j in 1..3)(sum(i in 1..3)(x[i,j]) = TOTAL);
constraint sum(i in 1..3)(x[i,i]) = TOTAL;
constraint sum(i in 1..3)(x[4-i,i]) = TOTAL;
@abeham
abeham / mathpuzzle_banana.mzn
Last active December 9, 2018 20:37
MiniZinc model that solves a math puzzle involving bananas and a camel
% A farmer has 300 bananas which she wants to sell at a market 100km away.
% Her camel can carry 100 bananas at once, and eats one banana per km.
% What is the most bananas she can bring to the market?
int: capacity = 100;
int: distance = 100;
int: init_stock = 300;
int: maxtrips = ceil(init_stock / capacity);
int: maxlegs = 4; % maximum amount of legs the journey is partitioned into, a leg consists of hauling a certain load over a certain distance
@abeham
abeham / git-layout-for-client-customizations.txt
Last active January 23, 2021 09:51
Discusses approaches to structure a git repository for software that is customized for several clients
Consider a software that is customized for each client. It contains common components, modules, and
client-specific customizations thereof. For instance,
Common
+ Common.ClientA
+ Common.ClientB
ModuleA
+ ModuleA.ClientB
ModuleB
+ ModuleB.ClientA
public int BinarySearch<T>(IList<Tuple<T, double>> values, T value, IComparer<T> comparer = null) {
if (values.Count == 0) return -1;
if (comparer == null) comparer = Comparer<T>.Default;
var lower = 0;
var upper = values.Count - 1;
while (lower <= upper) {
var mid = (lower + upper) / 2;
var result = comparer.Compare(value, values[mid].Item1);
if (result == 0) return mid;
else if (result < 0) { // value < values[mid]
It would be nice in C# to have a foreach-else.
I would like the else branch to execute when the collection was empty.
In that sense, either I loop over a collection OR I execute this code.
This would change
var empty = true;
foreach (var e in enumeration) {
empty = false;
// ...