Skip to content

acharaakshit/RMiniZinc

Repository files navigation

R INTERFACE TO MINIZINC

TABLE OF CONTENTS

INTRODUCTION

rminizinc is aimed towards providing the R users an interface to MiniZinc. Various functionalities are providing for users that are comfortable with MiniZinc and use some results in their analysis in R and for users that are less confident in MiniZinc and want to create MiniZinc models and obtain results using R. The package vignette contains a basic demonstration of all the features of the package and explains how to interpret the results.

INSTALLATION

NOTE: This package is compatible with MiniZinc 2.5.5.

  1. Build libminizinc

First, You need to download the libminizinc 2.5.5 release and build libminizinc library for MiniZinc to work properly.

Please follow these steps for Linux:

  • Download the libminizinc 2.5.5 release from https://github.com/MiniZinc/libminizinc/releases.
  • Extract the downloaded tar.gz or zip (for Windows) and name the extracted folder libminizinc.
  • cd libminizinc/
  • sudo sed -i '3 i set(CMAKE_POSITION_INDEPENDENT_CODE ON)' CMakeLists.txt
  • sudo cmake CMakeLists.txt
  • sudo make
  • sudo make install

Similarly, build libminizinc on Windows (can use cygwin) and OSX.

If sed command doesn't work for you, just add set(CMAKE_POSITION_INDEPENDENT_CODE ON) in the 3rd line (or any empty line in the starting) of CMakeLists.txt and follow the next steps.

  1. Get Solver Binaries

Solvers are required to solve the MiniZinc models. The solvers currently supported by rminizinc are Chuffed, FindMUS and Gecode. Any solver can be selected based on the type of problem that is required to be solved.

Now download the solver binaries to be able to solve the models and achieve full functionality of the package.

To get the solver binaries, the Users can download the MiniZinc binary bundles for Windows, MAC OS or Linux from https://www.minizinc.org/software.html and the provide the path to the bin folder of the MiniZinc bundle folder as the --with-bin argument. All the required solver binaries are present in that folder. The solver binary corresponding to Gecode will be fzn-gecode, FindMUS will be findMUS, Chuffed will be fzn-chuffed (.exe extentions will be there on Windows for eg. fzn-gecode.exe). ALternatively, if you don't want to keep the MiniZinc bundle, you can copy the solver binaries to another folder and just provide the path to that folder with --with-bin.

Once these steps are over, you just need to re-install rminizinc by using

install.packages("rminizinc", configure.args="--with-mzn=/path/to/libminizinc --with-bin=/path/to/bin")

NOTE: Please don't use \ at the end of the path given to --with-bin as it will cause some solver configuration issues.

Please note that if path arguments are not passed along with the installation (as --with-mzn), the default path /usr/local/lib for Linux and OSX, and C:/Program Files/ for Windows will be chosen but only if libminizinc in present in these default paths.

FEATURES

  • Parse a MiniZinc model and get the details as a named list in R.
  • Find the model parameters which have not been assigned a value yet.
  • Set the values of unassigned parameters. (Scope needs to be extended)
  • Solve a model and get parsed solutions as a named list in R.
  • Create your own MiniZinc model in R using the R6 classes from MiniZinc API mirror (Note that the API mirror only includes the relevant functionalities to serialize various objects to MiniZinc along with some checks).
  • Use the setter and getter functions of R6 classes to manipulate a model.
  • Use the named list returned after parsing to initialize all the relevant objects in R, manipulate the model and serialize back to MiniZinc.

SCOPE OF FEATURES

The features have been tested over a wide variety of problems but doesn't cover MiniZinc in its entirety. Please feel free to open an issue or submit a PR if you find any problems in the package. Any help towards making the installation easier is highly appreciated.

PROJECT STATUS

Under Development: Please note that the project is in it's early development stage and all the features haven't been tested for all of MiniZinc.

ACKNOWLEDGMENT