Coder Social home page Coder Social logo

crillab / autis Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 323 KB

AUTIS library allows parsing combinatorial problem instances for different common formats.

License: GNU Lesser General Public License v3.0

CMake 9.72% C++ 90.28%
constraint-programming cpp dimacs tootatis opb xcsp3

autis's Introduction

AUTIS - A library for parsing combinatorial problems

License: LGPL v3Build Status

Description

AUTIS library allows parsing combinatorial problem instances for different common formats. Currently, the following are supported:

AUTIS can feed any solver implementing the Universe interface.

Build

The latest release is available here

AUTIS is developed using C++ 17, CMake 3.23. Installing CMake is required if you want to build from source. To do so, after having installed all the needed tools, you will need to clone the project:

git clone https://github.com/crillab/autis.git --recursive
cd autis
mkdir build
cd build 
cmake .. -DCMAKE_BUILD_TYPE=RELEASE
cmake --build . 

Using CMake

This library is designed for simplified use in projects using CMake. To use this project, it is possible to create a sub-module in your project with the following commands:

git submodule add https://github.com/crillab/autis libs/autis
git submodule update --remote --recursive --init

And then add the following instructions in your CMakeLists.txt file:

add_subdirectory(libs/autis)
add_executable(your_solver solver.h solver.cpp)
target_link_libraries(your_solver autis)

Examples

For each of these examples, we consider that you have your own implementation of the ISolverFactory interface from the Universe library.

The paths to the .h files must be adapted.

Dimacs CNF

If you want to parse a CNF file like this one, you may use something similar to the following example.

#include <string>
#include <iostream>
#include "../libs/universe/universe/include/utils/ISolverFactory.hpp"
#include "../autis/core/parser.h"

int main(){
    std::string path ="examples/example.cnf";
    Universe::ISolverFactory* factory= new YourFactoryImplementation();
    auto solver = Autis::parse(path,*factory);
    auto result = solver->solve();
    auto solution = solver->solution();
    switch(result){
        case Universe::UniverseSolverResult::SATISFIABLE:
            auto solution = solver->solution();
            std::cout<<"SATISFIABLE"<<std::endl;
            break;
        case Universe::UniverseSolverResult::UNSATISFIABLE:
            std::cout<<"UNSATISFIABLE"<<std::endl;
            break;
        case Universe::UniverseSolverResult::UNKNOWN:
            std::cout<<"UNKNOWN"<<std::endl;
            break;
        case Universe::UniverseSolverResult::UNSUPPORTED:
            std::cout<<"UNSUPPORTED"<<std::endl;
            break;
    }
    return 0;
}

OPB

If you want to parse an OPB file like this one, you may use something similar to the following example.

#include <string>
#include <iostream>
#include "../libs/universe/universe/include/utils/ISolverFactory.hpp"
#include "../autis/core/parser.h"

int main(){
    std::string path ="examples/example.opb";
    Universe::ISolverFactory* factory= new YourFactoryImplementation();
    auto solver = Autis::parse(path,*factory);
    auto result = solver->solve();
    auto solution = solver->solution();
    switch(result){
        case Universe::UniverseSolverResult::SATISFIABLE:
            auto solution = solver->solution();
            std::cout<<"SATISFIABLE"<<std::endl;
            break;
        case Universe::UniverseSolverResult::UNSATISFIABLE:
            std::cout<<"UNSATISFIABLE"<<std::endl;
            break;
        case Universe::UniverseSolverResult::UNKNOWN:
            std::cout<<"UNKNOWN"<<std::endl;
            break;
        case Universe::UniverseSolverResult::UNSUPPORTED:
            std::cout<<"UNSUPPORTED"<<std::endl;
            break;
        case Universe::UniverseSolverResult::OPTIMUM_FOUND:
            auto solution = solver->solution();
            std::cout<<"OPTIMUM_FOUND"<<std::endl;
            break;
    }
    return 0;
}

XCSP

If you want to parse an XCSP3 file like this one, you may use something similar to the following example.

#include <string>
#include <iostream>
#include "../libs/universe/universe/include/utils/ISolverFactory.hpp"
#include "../autis/core/parser.h"

int main(){
    std::string path ="examples/example.xml";
    Universe::ISolverFactory* factory= new YourFactoryImplementation();
    auto solver = Autis::parse(path,*factory);
    auto result = solver->solve();

    switch(result){
        case Universe::UniverseSolverResult::SATISFIABLE:
            auto solution = solver->solution();
            std::cout<<"SATISFIABLE"<<std::endl;
            break;
        case Universe::UniverseSolverResult::UNSATISFIABLE:
            std::cout<<"UNSATISFIABLE"<<std::endl;
            break;
        case Universe::UniverseSolverResult::UNKNOWN:
            std::cout<<"UNKNOWN"<<std::endl;
            break;
        case Universe::UniverseSolverResult::UNSUPPORTED:
            std::cout<<"UNSUPPORTED"<<std::endl;
            break;
        case Universe::UniverseSolverResult::OPTIMUM_FOUND:
            auto solution = solver->solution();
            std::cout<<"OPTIMUM_FOUND"<<std::endl;
            break;
    }
    return 0;
}

Dependencies

autis's People

Contributors

romainwallon avatar thibaultfalque avatar

Watchers

 avatar  avatar  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.