Giter VIP home page Giter VIP logo

qualitativeclustering's Introduction

Qualitative Clustering via Integer Linear Programming

This repository presents the C++ implementation of the ILP models described in the article "Qualitative data clustering: a new Integer Linear Programming model".

Two header libraries are avaiable:

Table of contents

Example usage of ILP

ILP.h provides the class

ILP(std::string dataset)

where

  • dataset - name of the input dataset file

ILP class has a method ILP::execute(int modelType) that receives as parameter the type of ILP model you wish to run:

  • 0 - Runs the complete model (GM)
  • 1 - Runs model GM1
  • 2 - Runs model GM2
  • 3 - Runs model GM3

The following code excerpt shows how to run the complete model (GM) on the dataset 1-Lenses.txt

#include "ILP.h"

using namespace std;
using namespace qualitativeclustering;

int main()
{
    ILP ilp("data/1-Lenses.txt");
    cout << ilp.execute(0);
}

The output will be

Objective = 72
Constraints = 6072
Time Solve = 0.446455
Groups = 0 1 0 1 2 2 3 3 0 1 0 1 2 2 3 3 0 1 0 1 2 2 3 3

You must have IBM's CPLEX Optimizer™ 12> installed on your system to compile this code excerpt.

Let's suppose you are on Mac and <CPLEX_DIR> is the directory where CPLEX is installed on your system, the following command will compile this example:

g++ main.cpp -o main -I/<CPLEX_DIR>/cplex/include 
                     -I/<CPLEX_DIR>/concert/include
                     -DIL_STD 
                     -L/<CPLEX_DIR>/cplex/lib/x86-64_osx/static_pic/ 
                     -L/<CPLEX_DIR>/concert/lib/x86-64_osx/static_pic/ 
                     -lilocplex -lconcert -lcplex -lm -lpthread -std=c++11

For more information regarding setting up CPLEX on Linux/Mac/Windows:

Example usage of LPCreator

LPCreator.h provides the method to create ILP models in LP format

void createLP(std::string dataset, std::string LPfilename, int modelType)

where

  • dataset - name of the input dataset file
  • LPfilename - name of the output LP file
  • modeltype - type of model to create:
    • 0 - Create the complete model (GM)
    • 1 - Create GM1 model
    • 2 - Create GM2 model
    • 3 - Create GM3 model

The following code excerpt shows how to create an LP file that represents the complete model (GM) for the dataset 1-Lenses.txt:

#include "LPCreator.h"

using namespace std;
using namespace qualitativeclustering;

int main()
{
    createLP("data/1-Lenses.txt", "1-Lenses-GM.lp", 0);
}

The output will be a file in CPLEX LP format that can be used on any compatible solver.

LPCreator.h is a single header-only library. Hence, to compile this code excerpt just type on Linux/Mac:

g++ main.cpp -o main -std=c++11

qualitativeclustering's People

Contributors

luizhnlorena avatar

Watchers

James Cloos 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.