Giter Club home page Giter Club logo

chr-linear-equation-solver's Introduction

Linear Equation Solving using CHR

This project implements a constraint solver written in Constraint Handling Rules (CHR). It supports two solving strategies:

  • gaussian.pl: Gaussian Elimination
  • variable_elimination.pl: Variable Elimination

Requirements

The constraint solvers are implemented as Prolog modules. They have been tested with SWI-Prolog.

Usage

The modules can be directly loaded by SWI-Prolog using the following command:

swipl -s gaussian.pl

or

swipl -s variable_elimination.pl

Equations are specified by eq/2 constraints using Prolog's logical variables. To specify a + b = 2, the constraint eq(A+B,2) should be added.

Examples

?- eq(A+B, 2), eq(A-B, 0).
% A = 1, B = 1 .

?- eq(3*A-B, C), eq(A+2*C, 4-4*B), eq(2*B+C, 1).
% A = 2.0, B = -5.0, C = 11.0 .

?- eq(10*A+12*B, 38), eq(15*A+2*B, 19.4).
% A = 0.98, B = 2.35 .

?- eq(A + 2*B + 3*C, 3), eq(3*A - B + 2*C, 1), eq(2*A + 3*B - C, 1).
% A = 0.0714286, B = 0.5, C = 0.642857 .

?- eq(A-B, 2*B-5), eq(B-4*A+C, 6), eq(2*A+3*B, 3-C).
% A = -0.95, B = 1.35, C = 0.85 .

?- eq(6*A-B+C, 12*D-5), eq(-2*B-8, -6*A+8*D-2*C), eq(2*C, 4*D-3*A+5), eq(3*A, 9+4*D+B).
% A = 13.0, B = 6.0, C = -5.0, D = 6.0 .

?- eq(A+B, 0), eq(A+B, 1).
% false.

chr-linear-equation-solver's People

Contributors

fnogatz avatar

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.