Coder Social home page Coder Social logo

extremal-optimization's Introduction

C++ Implementation of Extremal Optimization for Modularity and In-block Nestedness

This code is a C++ program built on Visual Studio 2022 17.4.4.

Requirements

Operating System: Windows

Compiler: MSVC 14.34, igraph C library 0.9.9 (https://igraph.org/c/html/0.9.9/)

Usage

Command line

<exe_path> <csv_path> <object_flag> <alpha> <recursive> <loop>

Input

  1. exe_path: The path of the executable file built from the source code. The file eo.exe can be directly used.
  2. csv_path: The path of the CSV file that records the adjacency matrix of a network. Given a 3-node network, the content in the CSV file should be like:
0,1,1
1,0,1
1,1,0 
  1. object_flag: A binary variable decides the optimization target, 0 for modularity-based optimization, 1 for in-block nestedness-based optimization.
  2. alpha: The parameter α in the process of extremal optimization. If the optimized value is not improved in α*N steps(N-the number of nodes), the optimization process will stop.
  3. recursive: The number of times the whole network will be recursively partitioned. In the first recursion, the whole network will be split into two partitions. In the second recursion, each partition will be split into two smaller partitions.
  4. loop: The number of times the code will run, corresponding to the number of optimized values/partitions.

output

The optimized results will be saved in a CSV file named by the above input parameters, stored in csv_path.

  1. For modularity-based optimization(object_flag = 0), the results should be like:
<Q1>
<R1>
<C1>
<T1>      
<Q2>
<R2> 
<C2>
<T2>      
...

Qx: The optimized modularity in the xth loop.

Rx: The block index of each row node(country, company, etc.), in the xth loop.

Cx: The block index of each col node(product, technology, etc.), in the xth loop.

Tx: The running time of the xth loop.

  1. For in-block nestedness-based optimization(object_flag = 1), the results should be like:
<N>    
<I1>    
<R1> 
<C1>
<T1>      
<I2>      
<R2>      
<C2>
<T2>      
...  

N: The value of global nestedness.

Ix: The optimized in-block nestedness in the xth loop.

Rx: The block index of each row node(country, company, etc.), in the xth loop.

Cx: The block index of each col node(product, technology, etc.), in the xth loop.

Tx: The running time of the xth loop.

By computing the ratio N/Ix, we can determine whether nesting is a local or global attribute.

Example

File structure

C:\Users\Administrator\eo_ibn
│  eo.exe
│  matrix.csv

Command shell

C:\Users\Administrator>cd eo_ibn
C:\Users\Administrator\eo_ibn>eo.ex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 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0
running time 0.178s
0.147363
0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1
0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1
running time 0.135s

extremal-optimization's People

Contributors

ar23i9s avatar

Stargazers

 avatar

Watchers

 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.