Skip to content

Instantly share code, notes, and snippets.

@kgadek
kgadek / logtest.py
Last active August 29, 2015 14:23
logtest.py
from contextlib import contextmanager, closing
import logging
from logging.handlers import QueueHandler
import multiprocessing
from multiprocessing.pool import Pool
from multiprocessing.queues import Queue
@contextmanager
def background_process(x):
2015-06-19 11:36:00922 pr:48518 evotools.run_parallel DEBUG msg:Starting the worker. args:(('kursawe', 'IMGA+OMOPSO'), [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500], 0, '3')
2015-06-19 11:36:00923 pr:48518 evotools.run_parallel DEBUG msg:Renice the process PID:48518 by 3
2015-06-19 11:36:00923 pr:48518 evotools.run_parallel DEBUG msg:Getting random seed
2015-06-19 11:36:00924 pr:48518 evotools.run_parallel DEBUG msg:Starting preparation
2015-06-19 11:36:00924 pr:48518 evotools.run_parallel DEBUG msg:Preparing OMOPSO for kursawe
2015-06-19 11:36:00924 pr:48518 evotools.run_parallel DEBUG msg:driver class:∅
2015-06-19 11:36:00929 pr:48518 evotools.run_parallel DEBUG msg:Starting with config containing meta-parameters
2015-06-19 11:36:00930 pr:48518 evotools.run_parallel DEBUG msg:config: {'__metaconfig__populationsize': 100}
2015-06-19 11:36:00930 pr:48518 evotools.run_parallel DEBUG msg:Per-problem config: {'fitnesses': [<function fit_a at 0x1
diff --git a/algorithms/HGS/HGS.py b/algorithms/HGS/HGS.py
index f382fca..3039abb 100644
--- a/algorithms/HGS/HGS.py
+++ b/algorithms/HGS/HGS.py
@@ -26,7 +26,8 @@ class HGS(DriverGen):
crossover_variance, sprouting_variance,
mutation_variance, branch_comparison,
metaepoch_len, driver, max_children,
- mutation_probability=0.05, sproutiveness=1):
+ mutation_probability=0.05, sproutiveness=1,
@kgadek
kgadek / Makefile.patch
Created May 29, 2015 22:11
Patch for freebsd-port math/gmp to work on Raspberry Pi 2B
--- Makefile 2015-05-30 00:08:53.000000000 +0200
+++ MakefileRPi 2015-05-30 00:08:22.000000000 +0200
@@ -37,7 +37,8 @@
CONFIGURE_ENV+= ABI="64"
.endif
.else
-CONFIGURE_ENV+= ABI="32"
+CONFIGURE_ENV+= ABI="standard"
+CONFIGURE_ARGS+=--enable-assembly=no
.endif
@kgadek
kgadek / drivergen.py
Last active August 29, 2015 14:21
prototyp DriverGen
class DriverGen:
def __init__(self):
pass
def population_generator():
# raise NotImplementedError
current_cost = 0
finalized_pop = []
while True:
# Kojarzycie WALL-E? No to ten statek wielki nazywał się Axiom.
@kgadek
kgadek / kata_brainfuck.hs
Created May 1, 2015 22:58
Brainfuck interpreter with handcrafted lenses. Catamorphism not included though :<
{-# LANGUAGE RankNTypes, RecordWildCards #-}
import Data.Char
import Data.Functor.Identity
import Control.Applicative
{-
Inspired from real-world Brainf**k, we want to create an interpreter of that language which will
support the following instructions (the machine memory or 'data' should behave like a potentially
infinite array of bytes, initialized to 0):
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Resolving dependencies...
Configuring evil-pareto-0.0.0.0...
Building evil-pareto-0.0.0.0...
Preprocessing executable 'evil-pareto' for evil-pareto-0.0.0.0...
[1 of 6] Compiling EA.Multiobjective.Space.Cartesian ( src/EA/Multiobjective/Space/Cartesian.hs, dist/build/evil-pareto/evil-pareto-tmp/EA/Multiobjective/Space/Cartesian.o )
[2 of 6] Compiling RandMonadT ( src/RandMonadT.hs, dist/build/evil-pareto/evil-pareto-tmp/RandMonadT.o )
[3 of 6] Compiling RandTools ( src/RandTools.hs, dist/build/evil-pareto/evil-pareto-tmp/RandTools.o )
[4 of 6] Compiling EA ( src/EA.hs, dist/build/evil-pareto/evil-pareto-tmp/EA.o )
#include <iostream>
#include <cstdio>
#include <cstring> // tutaj jest zdefiniowany `strcpy` i `strncpy`
using namespace std;
struct osoba{
char imie[20];
char nazwisko[20];
int wiek;
@kgadek
kgadek / pocisk.hs
Last active August 29, 2015 14:17
-- Jest pudełko a w środku pewna ilość kulek. Każda kulka ma unikalny numer. Dokonaliśmy N losowań, w których
-- odnotowaliśmy wybór K różnych kulek.
-- Z jaką pewnością możemy stwierdzić, że w środku pudełka było K kulek? Innymi słowy: z jakim prawdopodobieństwem
-- wylosowaliśmy każdą z nich co najmniej raz?
import Data.Ratio
import Text.Printf
choose n k = product [k+1..n] % product [1..n-k]
entry n k i = (1 % (k + i) ^ n) * (choose (k+i) k)
@kgadek
kgadek / all.log
Created February 13, 2015 20:02
`go` from source (git checkout v1.4.1) on FreeBSD 10.1 @ Raspberry Pi B
[gogs@balrog ~/go/src]$ ./all.bash
# Building C bootstrap tool.
cmd/dist
# Building compilers and Go bootstrap tool for host, freebsd/arm.
lib9
libbio
liblink
cmd/cc
cmd/gc