Skip to content

Instantly share code, notes, and snippets.

View kunigami's full-sized avatar
:octocat:
Working from home

Guilherme Kunigami kunigami

:octocat:
Working from home
View GitHub Profile
@kunigami
kunigami / example.tex
Created August 14, 2011 12:29
Example of a simple beamer code
\documentclass{beamer}
\usecolortheme{wolverine}
\useinnertheme{circles}
\useoutertheme{infolines}
\usefonttheme{default}
\title[Short title]{
Title
@kunigami
kunigami / gist:1144934
Created August 14, 2011 14:41
Plain sample table
\begin{table}
\caption{Table caption}
\centering
\begin{tabular}{l | r r | r r}
& \multicolumn{2}{>{c|}{A} & \multicolumn{2}{c}{B} \\
Foo & 1 & 2 & 1 & 2\\
\hline
1 & a & b & c & d \\
\hline
\end{tabular}
@kunigami
kunigami / gist:1144944
Created August 14, 2011 14:49
Colored sample table
\begin{table}
\caption{Table caption}
\centering
\rowcolors{1}{loco3blue!17}{loco3blue!7}
\begin{tabular}{l | r r | r r}
& \multicolumn{2}{>{\columncolor{loco3blue!17}}c|}{A} & \multicolumn{2}{>{\columncolor{loco3blue!17}}c}{B} \\
Foo & 1 & 2 & 1 & 2\\
\hline
1 & a & b & c & d\\
\hline
@kunigami
kunigami / svn_mime_filter.py
Created August 16, 2011 21:41
Checking SVN mime types when adding rather than when committing
################################################################################
# svn_mime_filter.py
# Script to check if any of the file does not match the svn mime type
#
# TODOs:
# 1 - Report only once files that have the same extension
################################################################################
import os
import re
@kunigami
kunigami / dinner.cpp
Created September 10, 2011 21:49
Google Code Jam 2011 - Round 2 - Problem C (Expensive Dinner)
#include <iostream>
#include <vector>
using namespace std;
typedef long long i64;
bool is_prime[1123123];
vector<i64> primes; // lista de primos
-- Original source: Real World Haskell, Chapter 27
-- URL: http://book.realworldhaskell.org/read/sockets-and-syslog.html
import Data.Bits
import Network.Socket
import Network.BSD
import Data.List
import SyslogTypes
data SyslogHandle =
{-# LANGUAGE FlexibleContexts, GeneralizedNewtypeDeriving,
PatternGuards, ScopedTypeVariables #-}
import Control.Concurrent (forkIO)
import Control.Concurrent.STM
import Control.Exception (catch, finally)
import Control.Monad.Error
import Control.Monad.State
import Data.Char (isControl)
import Data.List (nub)
import Control.Concurrent
transfer :: MVar Int -> MVar Int -> Int -> IO ()
transfer a b val = do
valA <- takeMVar a
valB <- takeMVar b
putMVar a (valA - val)
putMVar b (valB + val)
Nesse post falarei sobre as desigualdades de cobertura erguidas (em uma horrorosa tradução livre de <em>lifted cover inequalities</em>). A minha ideia inicial era comentar sobre cortes automáticos que resolvedores como o XPRESS inserem no programa para apertar o modelo. Há dois tipos de desigualdades usadas como cortes: as de cobertura erguidas e aquelas resultantes do procedimento de Chvátal-Gomory.
Como esse segundo método faz uso direto do <em>tableau</em> do simplex, antes eu gostaria de escrever um post revisando o primal simplex e o dual simplex. Por isso, ater-me-ei às coberturas erguidas.
Essas desigualdades surgiram a partir do problema da mochila binária. Vamos relembrar o problema: dado um conjunto de n itens -- cada qual com um peso e valor -- e uma mochila de capacidade b, queremos escolher um subconjunto de itens cuja soma dos pesos respeite à capacidade da mochila e cuja soma dos valores seja máxima.
Vamos supor que os valores dos itens sejam dados por <img src="http://www.codecogs.com/eq.l
(*
Implementation of a queue with two lists. The first list represents the front
of the queue and the second the end, reversed. Insertions are performed at the
beginning of the second queue (remember inserting at the beginning of the list
is more efficient). Removals are done at the front list.
When the removal of an element will leave the front list empty, an operation
is performed to reverse the second list and assign it to the first.
The invariant we keep is that if 'left' is empty then 'right' must empty as
well.
*)