shnarazk / mios Goto Github PK
View Code? Open in Web Editor NEWA SAT solver written in Haskell.
Home Page: https://gitlab.com/satisfiability01/mios/
License: GNU General Public License v3.0
A SAT solver written in Haskell.
Home Page: https://gitlab.com/satisfiability01/mios/
License: GNU General Public License v3.0
mios-1.4.0 uses it; 1.4.1 not so far.
Nonsense!
{-# LANGUAGE TypeFamilies, DataKinds, GADTs, StandaloneDeriving, FlexibleInstances #-}
module Clause where
-- import Unsafe.Coerce
data ClauseKind = OfNormal | NullCaluse | BinaryClause
data Clause (a :: ClauseKind) where
MkClause :: [Int] -> Clause 'OfNormal
MkBinaryClause :: Int -> Clause 'BinaryClause
instance Eq (Clause a) where
(MkBinaryClause a) == (MkBinaryClause b) = a == b
_ == _ = undefined
instance Show (Clause a) where
show (MkBinaryClause l) = "B{" ++ show l ++ "}"
show (MkClause _) = show "Clause"
-- data Clause (a :: ClauseKind) = Clause [Int] deriving (Eq, Show)
c :: [Clause 'OfNormal]
c = []
_layered and functional version_
Thu Feb 11 02:49 2016 Time and Allocation Profiling Report (Final)
mios-noinline-prof +RTS -p -RTS SR15m/manthey_DimacsSorter_30_4.cnf
total time = 2921.22 secs (2921219 ticks @ 1000 us, 1 processor)
total alloc = 1,669,657,684,504 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
getNthInt SAT.Solver.Mios.Data.FixedVecInt 34.3 67.8
propagateLit SAT.Solver.Mios.Solver 11.8 7.4
nextWatcher SAT.Solver.Mios.WatchList 11.0 2.4
pushWatcher SAT.Solver.Mios.WatchList 9.7 2.3
propagate SAT.Solver.Mios.Solver 7.6 1.2
clauseNew SAT.Solver.Mios.Solver 5.5 0.0
selectWatcher SAT.Solver.Mios.Clause 4.5 4.3
valueLit SAT.Solver.Mios.Solver 4.5 5.2
insertQueue SAT.Solver.Mios.Data.QueueOfBoundedInt 1.7 1.4
enqueue SAT.Solver.Mios.Solver 1.4 0.3
undoOne SAT.Solver.Mios.Solver 0.9 2.1
setNthInt SAT.Solver.Mios.Data.FixedVecInt 0.5 1.3
_low, raw and C
-ish version_
Thu Feb 11 19:07 2016 Time and Allocation Profiling Report (Final)
mios-noinline-prof +RTS -p -RTS SR15m/manthey_DimacsSorter_30_4.cnf
total time = 1363.96 secs (1363957 ticks @ 1000 us, 1 processor)
total alloc = 971,328,150,872 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
getNthInt SAT.Solver.Mios.Data.FixedVecInt 24.3 21.2
propagateLit SAT.Solver.Mios.Solver 13.4 14.1
pushWatcher SAT.Solver.Mios.WatchList 11.2 4.0
nextWatcher SAT.Solver.Mios.WatchList 11.1 4.1
propagate SAT.Solver.Mios.Solver 9.5 2.1
clauseNew SAT.Solver.Mios.Solver 6.3 6.9
valueLit SAT.Solver.Mios.Solver 5.5 18.1
selectWatcher SAT.Solver.Mios.Clause 4.5 7.4
insertQueue SAT.Solver.Mios.Data.QueueOfBoundedInt 2.0 2.5
enqueue SAT.Solver.Mios.Solver 1.7 0.5
sizeOfClause SAT.Solver.Mios.Clause 1.5 2.3
undoOne SAT.Solver.Mios.Solver 1.1 3.7
setNthInt SAT.Solver.Mios.Data.FixedVecInt 0.8 3.0
valueVar SAT.Solver.Mios.Solver 0.7 1.4
setNthClause SAT.Solver.Mios.Clause 0.3 1.2
comparison target: mios-WIP(unreleased 1.0.2)
Fri Feb 12 18:42 2016 Time and Allocation Profiling Report (Final)
mios-WIP-prof +RTS -p -RTS manthey_DimacsSorter_30_4.cnf
total time = 2477.18 secs (2477183 ticks @ 1000 us, 1 processor)
total alloc = 20,225,903,792 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
solve SAT.Solver.Mios.Solver 99.5 95.6
select SAT.Solver.Mios.Solver 0.2 4.2
should be removed.
Feature: a bug fix on DIMACS reader + the following micro tunings (or code-cleanup) from nowrap-with-inline branch
level
, activities
, reason
and seen
to var-indexed (1-based) vectorsVarHeap
spoils everything in all versions.
Some thought on types and kinds to use recent ghc features.
Slover.C
analyze_removable
(was litRedundant
)analyze_final
decisionLevel
LBD was implemented. But before committing it to master, I must make a release of a vanilla minisat implementation.
IORef
, Vector.Unboxed.Mutable singleton
, Data.Mutable
{-# LANGUAGE FlexibleInstances #-}
module Main where
newtype VecFam a = V [Int]
data AsVector
data AsStack
data AsQueue
class Gettable a where
get :: a -> [Int]
push :: a -> Int -> a
peep :: a -> Int
pop :: a -> a
type Vector = VecFam AsVector
type Stack = VecFam AsStack
type Queue = VecFam AsQueue
instance Gettable Vector where
get (V a) = a
instance Gettable Stack where
get (V a) = tail a
instance Gettable Queue where
get (V a) = reverse $ tail a
q = V [1 .. 5]
main :: IO ()
main = do
print $ get (q :: Vector)
print $ get (q :: Stack)
print $ get (q :: Queue)
It deserves to release.
ClauseManager
with WatcherList
; or rename to a better name"mios-1.4.0 (2d91fb9@2016-09-12)", 50, "SR15m/manthey_DimacsSorterHalf_37_6.cnf", 772.28
"mios-1.5@08-24", 50, "SR15m131/manthey_DimacsSorterHalf_37_6.cnf", 818.46
mios-71.1-671802c --benchmark=2010 --sequence=127 SC17main/g2-T50.2.0.cnf
mios-71.1-671802c --benchmark=2010 --sequence=139 SC17main/g2-T96.1.1.cnf
On complicated problems, mios
works fine when used as an executable like this:
$ stack run mios162 -- sudoku.dimacs
SATISFIABLE, saved to .ans_sudoku.dimacs for sudoku.dimacs
Example problem: https://gist.github.com/potocpav/97c84a24a45797b44a63a565295aec8b
It, however, fails on the same file when used as a library:
import SAT.Mios.Util.DIMACS.Reader
import SAT.Mios (CNFDescription(..), solveSAT)
main :: IO ()
main = do
clauses <- clauseListFromFile "sudoku.dimacs"
let nVars = (maximum . map abs $ concat clauses)
let descr = CNFDescription nVars (length clauses) "file"
l <- solveSAT descr clauses
print l
This sometimes shows Segmentation fault (core dumped)
, sometimes this:
simple: Data.Vector.Mutable: uninitialised element
CallStack (from HasCallStack):
error, called at ./Data/Vector/Mutable.hs:188:17 in vector-0.12.0.2-AoZ9EwUsgIW1yrOc105QXH:Data.Vector.Mutable
On large problems (>10k variables) it fails reliably. For less complicated problems (~2000 variables), the failures are intermittent. For small problems (~10 variables), it works.
Though the purpose of 1.0 is to translate the codes in the paper (EΓ©n, Niklas, and Niklas SΓΆrensson. "An extensible SAT-solver." Theory and applications of satisfiability testing. Springer Berlin Heidelberg, 2003.) and some parts from MiniSat 1.14 into a program written in Haskell, I found there are a lot of differences between the paper and MiniSat 1.14; version 1.14 is not close to the paper but to MiniSat 2.2. It makes difficult to develop mios further; most part of the solver core should be updated.
So stopping to improve the performance of the current mios 1.0.X based on the paper, I decided to switch the reference code to MiniSat 2.2 after the release of 1.0.3.
It is a shorter way to archive an expected high-performance SAT solver in Haskell.
analyzeRemovable
and 3 variables for analyze
familyreduceDB
needs sortOnActivity
!
analyze_removable
analyzeFinal
f.e.: manthey_DimacsSorter_28.cnf (SAT RACE 2015) contains:
p cnf 3553 11381
c Exactly One of a0_0_2380 (3) a0_1_2380 (4) a1_0_2380 (5) a1_1_2380 (6)
c -a0_0_2380 -a0_1_2380
-3 -4 0
c -a0_0_2380 -a1_0_2380
-3 -5 0
c -a0_0_2380 -a1_1_2380
-3 -6 0
c -a0_1_2380 -a1_0_2380
mios-1.0.1 and upper can't handle it correctly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.