npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wengerp/simple_doplo_solver

v1.2.1

Published

A simple doplo solver

Downloads

7

Readme

A simple Doplo Solver

A search algorithm for solving doplo ridles (https://www.doplo.ch/) using a heuristic backtracking algorithm. If it is run on standard hardware it is capable to solve up to 6x6 ridles. 7x7 ridles might taking hours and hours...

NEWS

I added a new CSP-based variation of the doplo solver to the repository. It is based on Essence 1.0, a language to describe problems as Constraint Satisfaction Problems (CSP). This approach is very strong. And since I used Savile Row (https://savilerow.cs.st-andrews.ac.uk) as environement it is possible to transform CSP-Problems to SAT instances. So called Satisfiability Problems deal with the NP = P Problem and therefore with the hardest problems to find solutions for. SAT-Solvers are incredibly mature software tools and are capable of solving 8x8 instances of Doplos in under a second. It might be possible to solve 9x9 instances. However, I don't know of any 9x9 instance to test this problem. If anybody happens to know of any 9x9 instances I would be interested.

How to use

  • Download Savile Row 1.9.0 (https://savilerow.cs.st-andrews.ac.uk/releases.html)
  • install (copy) Savile Row in a directory of your choice
  • change into the installation directory.
  • start Savile Row with the following command: [FULL_PATH_TO_THE_PROJECT_FILES]/doplov2.eprime [FULL_PATH_TO_THE_PROJECT_FILES]/doplov2.param -sat -run-solver -all-solutions
  • After about 1 second the programm finishes and there are a few new files in the project directory: doplov2.param.solution.0000001 (the solution) and doplov2.param.info (statistics)
  • of course you can also try other parameters or just generate the SAT-File in DIMACS format. The latter can be achieved in omitting the "-run-solver" parameter. You can then look into the (huge) DIMACS file and solve it with any SAT-Solver. However, you will then have to interpretate the solution yourself.

API

(HeuristicNode) startnode prepare((Int Array)restrictionsarray)
(HeuristicNode) resultnode search((HeuristicNode)startnode, [(Int)verbosecount])

(HeuristicNode) node.print() 
(HeuristicNode) node.sets = (Int Array)(Int Array) expectedresultarray 
restrictionsarray: an array of integers with the given restrictions (from top to down, then left to right).
expectedresultarray: a two dimensional array of integers (line by line from top to down).
if the search doesn't find any solution it will return null;

Usage Sample

const sds = require("@wengerp/simple_doplo_solver");
var startnode = sds.prepare([0, 3, 2, 6, 5, 0, 5, 3, 0, 0]);
const result = sds.search(startnode);
result.print();

verbose mode

You can add an additional parameter to the search call. This parameter denotes the frequency of the output on standard out. If for example you choose 100 then there will be an update of the verbose info every 100 loop runs. This means the higer the number the lower the update. If you specify 1 as the parameter value then every single loop run will update the infomation. Be aware that this might slow down the search.

Usage Sample

const sds = require("@wengerp/simple_doplo_solver");
var startnode = sds.prepare([0, 3, 2, 6, 5, 0, 5, 3, 0, 0]);
const result = sds.search(startnode,100);
result.print();

check external solutions

If for some reason you want to verify an external solution you can add the expected result to the HeuristicNode which is returned by the prepare call. The expected result must be entered as a two dimensional array of integers (line by line, top down).

Usage Sample

const sds = require("@wengerp/simple_doplo_solver");
var startnode = sds.prepare([0, 3, 2, 6, 5, 0, 5, 3, 0, 0]);
startnode.sets = [[3,1,0,0,2],[2,0,3,0,1],[0,2,0,1,3],[0,3,1,2,0],[1,0,2,3,0]];
const result = sds.search(startnode,100);
if (result) result.print(); else console.log("invalid solution");