Skip to content

Instantly share code, notes, and snippets.

View msakai's full-sized avatar

Masahiro Sakai msakai

View GitHub Profile
@msakai
msakai / umineko8challenge.als
Created January 10, 2011 11:20
うみねこのなく頃に8 のベルンの挑戦のAlloyモデル
// うみねこのなく頃に8 のベルンの挑戦のAlloyモデル
abstract sig Person { kill : set Person }
one sig
Krauss, Natsuhi, Jessica,
Eva, Hideyoshi, George,
Rudolf, Kyrie, Battler,
Rosa, Maria,
Nanjo,
Genji, Shannon, Kanon, Gouda, Kumasawa
extends Person {}
@msakai
msakai / fakecoin.als
Created January 13, 2011 00:29
贋金パズルのAlloyモデル
// 失敗版
sig Coin {}
abstract sig State {
  candidates : set Coin,
}
sig Branch extends State {
  left, right : set Coin, 
  eq, lt, gt : State
@msakai
msakai / FourierMotzkin.hs
Created January 18, 2011 23:42
Naïve implementation of Fourier-Motzkin Variable Elimination
{-# OPTIONS_GHC -Wall #-}
-----------------------------------------------------------------------------
-- |
-- Module : FourierMotzkin
-- Copyright : (c) Masahiro Sakai 2011
-- License : BSD-style
--
-- Maintainer : [email protected]
-- Stability : provisional
-- Portability : portable
@msakai
msakai / Simplex.hs
Created January 24, 2011 16:25
Naïve implementation of Simplex method
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wall #-}
-----------------------------------------------------------------------------
-- |
-- Module : Simplex
-- Copyright : (c) Masahiro Sakai 2011
-- License : BSD-style
--
-- Maintainer : [email protected]
-- Stability : provisional
@msakai
msakai / Cooper.hs
Created January 27, 2011 17:04
Naïve implementation of Cooper's algorithm
{-# OPTIONS_GHC -Wall #-}
-----------------------------------------------------------------------------
-- |
-- Module : Cooper
-- Copyright : (c) Masahiro Sakai 2011
-- License : BSD-style
--
-- Maintainer : [email protected]
-- Stability : provisional
-- Portability : portable
@msakai
msakai / LPFile.hs
Created February 24, 2011 17:37
A CPLEX lp format parser library
{-# OPTIONS_GHC -Wall -fno-warn-unused-do-bind #-}
-----------------------------------------------------------------------------
-- |
-- Module : LPFile
-- Copyright : (c) Masahiro Sakai 2011
-- License : BSD-style
--
-- Maintainer : [email protected]
-- Stability : provisional
-- Portability : portable
type S = ((Int,Int),(Int,Int),(Int,Int))
guess :: S -> S
guess ((a1,a2),(b1,b2),(c1,c2)) =
case (a1+b1) `compare` (b2+c1) of
EQ ->
if b1 < b2
then ((100,99),(99,100),(99,100))
else ((99,100),(100,99),(100,99))
LT ->
class SATSolver
def initialize
@cnt = 0
@ok = true
@clauses = []
@model = Hash.new
@watches = Hash.new
end
@msakai
msakai / TseitinEncoding.hs
Created March 24, 2011 12:58
Tseitin Encoding
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module TseitinEncoding
( Var
, Lit
, Clause
, CNF
, Formula
, CNFGenMonad (..)
, emitFormula
, CNFGen
@msakai
msakai / TuplingExample.hs
Created March 25, 2011 14:36
タプル化の簡単な例
module TuplingExample where
import Prelude hiding (even, odd)
even :: Int -> Bool
even n = if n==0 then True else odd (n-1)
odd :: Int -> Bool
odd n = if n==0 then False else even (n-1)