A MATLAB toolkit for sensor placement in water distribution systems #EPANET

*TestSplace.m to run sensor placement from Matlab console.*

Sensor Placement (S-PLACE) Toolkit

The `Sensor Placement (S-PLACE) Toolkit’ is used for computing at which locations to install contaminant sensors in water distribution systems to reduce the impact risks. The S-PLACE Toolkit is built on the mathematical framework previously proposed (Eliades and Polycarpou, 2010) and it has been designed to be user-friendly and modular, suitable for both the professional and the research community. The Toolkit is programmed in Matlab utilizing the EPANET libraries. The modular software architecture allows each module to be accessed independently through stand-alone functions. Furthermore, the Toolkit allows the user to add, modify or remove methods and network elements, as well as to program new functions. The use of the software is illustrated using benchmark networks which capture different types of real network topologies, such as looped and branched networks.

How to cite
title = {{Sensor Placement in Water Distribution Systems
Using the S-PLACE Toolkit}},
year = 2014,
publisher = {Zenodo},
month = apr,
doi = {10.1016/j.proeng.2014.02.066},
url = {https://doi.org/10.1016/j.proeng.2014.02.066}

  • Eliades, D. G., Kyriakou, M., and Polycarpou, M. M. (2014). Sensor placement in water distribution systems using the S-PLACE Toolkit. Proc12th International Conference on Computing and Control for the Water Industry, CCWI2013, Procedia Engineering, Elsevier, 70, pp. 602-611 (https://doi.org/10.1016/j.proeng.2014.02.066)

Mathematical Framework

  • Eliades, D., Polycarpou, M., 2010. A fault diagnosis and security framework for water systems. IEEE Transactions on Control Systems Technology 18, 1254�1265. ref

S-PLACE Toolkit

Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy)

Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission – subsequent versions of the EUPL (the “Licence”);

Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an “AS IS” basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the Licence for the specific language governing permissions and limitations under the Licence.


EPANET is public domain software that may be freely copied and distributed.


The Toolkit works with your 32-bit Matlab version, and can work with 64-bit computers by using a suitable epanet.dll

  1. To download, press here: https://github.com/KIOS-Research/splace-toolkit/archive/master.zip
  2. Unzip this file in a folder, and set this folder as the “active” matlab path.
  3. Next, you just run the SPLACE.m file. This will load the GUI. From there, you can load any *.inp files.
  4. Next, you need to select and run a series of algorithms, to solve the sensor placement. You first need to create a parameter set for all scenarios (GridParameters). Next, simulate the scenarios (SimulateAll). Next, compute the impact matrix e.g. with metric the contaminated water consumption volume (CWCV) and finally, solve the optimization (Exhaustive or Evolutionary). Depending on whether you have the evolutionary toolkit, the evolutionary multi-objective algorithm might not work, but you can use whatever optimization you prefer.
  5. All algorithms are modular, i.e. they all read/create certain files with certain structure. If you want to create a new algorithm e.g. for optimization, just copy/paste one of the existing algorithms, change its name and change the code accordingly, the toolkit will automatically recognize the new functions.


Fix EPANET pipe lengths

Using EPANET-Matlab-Toolkit

clear all; close all;

% Load paths

% Load file
d = epanet('test.inp');

% Get link node indices # from node to node
indices = d.getLinkNodesIndex;

% Return initial length of pipes

% Fixed length of pipes
for link_ind = 1:d.LinkCount
    ind_Node1 = indices(link_ind, 1);
    ind_Node2 = indices(link_ind, 2);
    [latlons] = d.getNodeCoordinates([ind_Node1, ind_Node2]);
    X = [latlons(1, :);latlons(2, :)];
    fixLength = pdist(X, 'euclidean');
    d.setLinkLength(link_ind, fixLength);

% Rerurn link lengths


% Unload dll

Or via executable:


Question thread at community.wateranalytics.org



EMT v2.2 prelease

Current version EMT v2.1.8

The EPANET-Matlab Toolkit is an open-source software, originally developed by the KIOS Research Center for Intelligent Systems and Networks of the University of Cyprus which operates within the Matlab environment, for providing a programming interface for the latest version of EPANET, a hydraulic and quality modeling software created by the US EPA, with Matlab, a high-level technical computing software. The goal of the EPANET Matlab Toolkit is to serve as a common programming framework for research and development in the growing field of smart water networks.

The EPANET-Matlab Toolkit features easy to use commands/wrappers for viewing, modifying, simulating and plotting results produced by the EPANET libraries.

For support, please use the OWA community forum: http://community.wateranalytics.org/

How to cite

D.G. Eliades, M. Kyriakou, S. Vrachimis and M.M. Polycarpou, “EPANET-MATLAB Toolkit: An Open-Source Software for Interfacing EPANET with MATLAB”, in Proc. 14th International Conference on Computing and Control for the Water Industry (CCWI), The Netherlands, Nov 2016, p.8. (doi:10.5281/zenodo.831493)

author={Eliades, Demetrios G. and Kyriakou, Marios and Vrachimis, Stelios and Polycarpou, Marios M.}, 
title={EPANET-MATLAB Toolkit: An Open-Source Software for Interfacing EPANET with MATLAB}, 
booktitle={Proc. 14th International Conference on Computing and Control for the Water Industry (CCWI)}, 
address = {The Netherlands},

How to install necessary compilers

In order to use the EPANET-MATLAB-Toolkit the MinGW-w64 compiler must be installed:

How to install MinGW-w64 compiler #Matlab

In case you have a version of Matlab older than 2015b install the Windows SDK compiler:

How to install Windows SDK compiler compiler #Matlab

Video tutorials

How to use EPANET-MATLAB-Toolkit

How to use EPANET-MATLAB-Toolkit

Rotate EPANET water network

Rotate water network via EPANET-MATLAB-Toolkit

Change/set the flow units of EPANET Input Files

Set flow units of input file #EPANET-MATLAB-Toolkit #EMT #EPANET