Giter VIP home page Giter VIP logo

hakank / hakank Goto Github PK

View Code? Open in Web Editor NEW
356.0 44.0 74.0 36.41 MB

My public programs and models - mostly combinatorial problems and puzzles

License: MIT License

HTML 8.25% Prolog 15.60% Java 5.08% C++ 2.77% Ruby 0.71% Python 15.02% C# 2.09% Shell 0.02% Mathematica 0.43% Perl 0.13% Scala 1.86% OpenEdge ABL 1.26% AMPL 2.42% Raku 0.20% JavaScript 34.16% R 0.01% Julia 7.09% PDDL 2.91%
constraint-programming constraint-satisfaction minizinc picat z3py gecode essence jacop ampl comet

hakank's Issues

spp.mzn loop bug

spp.mzn when applying to indirect graph may generate graph loops.

e.g. 1->2, 2->1 may present in the same time in a result.

picat > 3_jugs_mip.pi doesn't work

Error message

GLPSOL--GLPK LP/MIP Solver 5.0
Parameter(s) specified in the command line:
--cpxlp -o __tmp.sol __tmp.lp
Reading problem data from '__tmp.lp'...
__tmp.lp:28: multiple use of variable 'X2' not allowed
CPLEX LP file processing error
*** error(failed,main/0)

Bug in cabling.py

I'm looking to use OR-Tools to replicate your CPMpy model https://github.com/hakank/hakank/blob/master/cpmpy/cabling.py
Lines 177-179, in the second model, say:

  for i in range(n):
    a,b,num = cable_struct[i]
    model += [t[i] == abs(x[a]-x[b])*num]

I believe that the range should be:
for i in range(len(cable_struct)):
The current code returns the correct solution because the example just happens to have n == len(cable_struct) but that isn't true in general.

whats the type of license here

Hi Hakan,

I very much like your code. It makes for example good use of Prolog
comments. But I am little bit at loss. What is the license of all that?

Best Regards

An help for Picat

I'm sorry for contacting you here, but I'm having some trouble with Picat and I wish ask you for help if you can.

(the question is not strictly related to this repository)

I'm implementing a solver for {log} language in Picat (you can find my code here).

The trouble

I'm parsing a formula given in input by the user with the picat built-in function parse_term/2. The formula is made by a list of terms like this: [eq(X,1), ...].
The parse_term/2 function returns a term representing my formula, but also a map for name of variables and variables themselves.

My objective is to store this map in a global variable and retrieve it when the solver solves the formula to convert back the variables to their original names.

The problem is that I put the map into a global map using get_global_map().put(k, V) and then when I retrieve it using get_global_map().get(k) the keys of this map are unchanged while values (real variables) have changed.

Why this happens? What I'm doing wrong?

Code references

Here is where I would convert back variables to their real names:

And here is the function that should convert back variables. Note that this is not working only if I use vars map retrieved from the global map; passing directly the vars map makes this works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.