├── RESULTS └── results.txt ├── .gitignore ├── HELP ├── ucy.jpg ├── about.fig ├── kios.jpg ├── white.png ├── splace2.png ├── Instructions.html └── about.m ├── SPLACE.fig ├── SPLACE ├── IMPACT │ ├── CWCV │ │ ├── CWCV.fig │ │ ├── ComputeImpactMatrices.m │ │ └── CWCV.m │ └── PI │ │ └── PI.m ├── MISC │ ├── paretofront.mexw32 │ ├── paretofront.mexw64 │ ├── cartesianProduct.m │ ├── license.txt │ ├── paretofront.m │ ├── paretofront.c │ ├── linspaceNDim.m │ └── progressbar.m ├── SIMULATE │ ├── SimulateAll │ │ ├── SimulateAll.fig │ │ ├── runMultipleScenarios.m │ │ └── SimulateAll.m │ └── SimulateRandom │ │ ├── SimulateRandom.fig │ │ ├── runRandomScenarios.m │ │ └── SimulateRandom.m ├── OPTIMIZATION │ ├── Exhaustive │ │ ├── Exhaustive.fig │ │ ├── ExhaustiveOptimization.m │ │ └── Exhaustive.m │ └── Evolutionary │ │ ├── Evolutionary.fig │ │ └── EvolutionaryOptimization.m └── SCENARIOS │ └── GridParameters │ ├── GridParameters.fig │ ├── ReleaseLocation.fig │ ├── SensingLocation.fig │ ├── DefaultParameters.m │ ├── gridmethod.m │ ├── GetGuiParameters.m │ ├── ReleaseLocation.m │ └── SensingLocation.m ├── EPANET-MATLAB-Toolkit ├── 32bit │ ├── epanet2.dll │ ├── epanet2.exe │ ├── epanet2d.exe │ ├── epanetmsx.dll │ ├── epanetmsx.exe │ └── epanetmsx.h └── 64bit │ ├── epanet2.dll │ ├── epanet2.exe │ ├── epanet2d.exe │ ├── epanetmsx.dll │ ├── epanetmsx.exe │ └── epanetmsx.h ├── EPANET-Licence.txt ├── Sensors_report.txt ├── TestSplace.m ├── README.md ├── SPLACE.prj ├── NETWORKS ├── Net1_Rossman2000.inp ├── Anytown_Walski1987.inp └── Net2_Rossman2000.inp └── Licence.txt /RESULTS/results.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.asv 3 | -------------------------------------------------------------------------------- /HELP/ucy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/HELP/ucy.jpg -------------------------------------------------------------------------------- /SPLACE.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE.fig -------------------------------------------------------------------------------- /HELP/about.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/HELP/about.fig -------------------------------------------------------------------------------- /HELP/kios.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/HELP/kios.jpg -------------------------------------------------------------------------------- /HELP/white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/HELP/white.png -------------------------------------------------------------------------------- /HELP/splace2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/HELP/splace2.png -------------------------------------------------------------------------------- /SPLACE/IMPACT/CWCV/CWCV.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/IMPACT/CWCV/CWCV.fig -------------------------------------------------------------------------------- /SPLACE/MISC/paretofront.mexw32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/MISC/paretofront.mexw32 -------------------------------------------------------------------------------- /SPLACE/MISC/paretofront.mexw64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/MISC/paretofront.mexw64 -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/32bit/epanet2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/32bit/epanet2.dll -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/32bit/epanet2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/32bit/epanet2.exe -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/64bit/epanet2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/64bit/epanet2.dll -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/64bit/epanet2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/64bit/epanet2.exe -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/32bit/epanet2d.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/32bit/epanet2d.exe -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/32bit/epanetmsx.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/32bit/epanetmsx.dll -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/32bit/epanetmsx.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/32bit/epanetmsx.exe -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/64bit/epanet2d.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/64bit/epanet2d.exe -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/64bit/epanetmsx.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/64bit/epanetmsx.dll -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/64bit/epanetmsx.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/EPANET-MATLAB-Toolkit/64bit/epanetmsx.exe -------------------------------------------------------------------------------- /SPLACE/SIMULATE/SimulateAll/SimulateAll.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/SIMULATE/SimulateAll/SimulateAll.fig -------------------------------------------------------------------------------- /SPLACE/OPTIMIZATION/Exhaustive/Exhaustive.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/OPTIMIZATION/Exhaustive/Exhaustive.fig -------------------------------------------------------------------------------- /SPLACE/OPTIMIZATION/Evolutionary/Evolutionary.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/OPTIMIZATION/Evolutionary/Evolutionary.fig -------------------------------------------------------------------------------- /SPLACE/SIMULATE/SimulateRandom/SimulateRandom.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/SIMULATE/SimulateRandom/SimulateRandom.fig -------------------------------------------------------------------------------- /SPLACE/SCENARIOS/GridParameters/GridParameters.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/SCENARIOS/GridParameters/GridParameters.fig -------------------------------------------------------------------------------- /SPLACE/SCENARIOS/GridParameters/ReleaseLocation.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/SCENARIOS/GridParameters/ReleaseLocation.fig -------------------------------------------------------------------------------- /SPLACE/SCENARIOS/GridParameters/SensingLocation.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KIOS-Research/splace-toolkit/HEAD/SPLACE/SCENARIOS/GridParameters/SensingLocation.fig -------------------------------------------------------------------------------- /EPANET-Licence.txt: -------------------------------------------------------------------------------- 1 | Description 2 | 3 | EPANET is software that models water distribution piping systems. EPANET is public domain software that may be freely copied and distributed. It is a Windows 95/98/NT/XP program. EPANET performs extended period simulation of the water movement and quality behavior within pressurized pipe networks. -------------------------------------------------------------------------------- /SPLACE/MISC/cartesianProduct.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright: Amro, 2010 (http://stackoverflow.com/users/97160/amro) 3 | Stack Overflow, Creative Commons Attribution-ShareAlike 3.0 Unported License 4 | http://stackoverflow.com/questions/4165859 5 | %} 6 | 7 | function result = cartesianProduct(sets) 8 | c = cell(1, numel(sets)); 9 | [c{:}] = ndgrid( sets{:} ); 10 | result = cell2mat( cellfun(@(v)v(:), c, 'UniformOutput',false) ); 11 | end -------------------------------------------------------------------------------- /Sensors_report.txt: -------------------------------------------------------------------------------- 1 | ------S-PLACE------ [Exhaustive Method] 2 | 3 | ------Sensors-Placement: 1 4 | mean = 42540.42 max = 218610.01 NodesID: 12 5 | ------Sensors-Placement: 2 6 | mean = 23495.04 max = 153720.00 NodesID: 11 22 7 | mean = 25398.25 max = 60480.00 NodesID: 21 22 8 | ------Sensors-Placement: 3 9 | mean = 17926.36 max = 60480.00 NodesID: 11 22 31 10 | 11 | ---------------------------------------------------- 12 | 13 | Network file: "Net1_Rossman2000.inp" 14 | 15 | Report by S-PLACE Toolkit. -------------------------------------------------------------------------------- /HELP/Instructions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | 5 |               6 |

   Licence File

   

© 2013 KIOS Research Center for Intelligent Systems and Networks


7 |      Credits
8 |      ------------------------
9 |      Marios Kyriakou
10 |      Demetrios Eliades 11 |

12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /SPLACE/IMPACT/PI/PI.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} -------------------------------------------------------------------------------- /TestSplace.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | %% S-PLACE 16 | function Y=TestSplace 17 | addpath(genpath(pwd)); 18 | clear 19 | clc 20 | file0='file0'; % in gidmethod 21 | B=epanet('Net1_Rossman2000.inp'); 22 | P=gridmethod(B); 23 | runMultipleScenarios(file0, 1); %file0 name & 1=use binary or 0=without binary 24 | ComputeImpactMatrices(file0); 25 | 26 | numberofSensors=3; 27 | ExhaustiveOptimization(file0,numberofSensors); %EvolutionaryOptimization 28 | load('file0.y0','-mat'); 29 | 30 | B.unload 31 | end 32 | -------------------------------------------------------------------------------- /SPLACE/MISC/license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2005, Steve Hoelzer 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the distribution 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /SPLACE/SCENARIOS/GridParameters/DefaultParameters.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function P=DefaultParameters(varargin) 16 | if isstruct(varargin{1}) 17 | B=varargin{1}.B; 18 | else 19 | B=varargin{1}; 20 | end 21 | disp('Create Scenario Parameters') 22 | 23 | P.Method='grid'; 24 | P.MethodParameter=NaN; 25 | 26 | %TIMES 27 | P.PatternTimeStep=B.TimePatternStep; 28 | P.SimulationTime=48; %e.g.48 in Hours 29 | 30 | 31 | %CONTAMINANT (A) 32 | P.SourceInjectionRate=10; %mg/L (Concentration), instead of mg/minute 33 | P.SourceDuration=2; %hours 34 | P.SourceParameters={'SourceInjectionRate','SourceDuration'}; 35 | P.SourceValues={P.SourceInjectionRate, P.SourceDuration}; 36 | P.SourcePrc={0, 0}; %EDITABLE 37 | P.SourceSamples={1,1}; %EDITABLE 38 | 39 | %CONTAMINANT (B) 40 | P.SourcesMaxNumber=1; % maximum number of simultaneous sources (including 1,2..) 41 | P.SourcesInjectionTimes=[0 24]; %from...to in hours 42 | %P.SourcesInjectionTimes=[4 5]; %from...to in hours 43 | P.SourcesNodeIndices=1:B.NodeCount; 44 | P.SensingNodeIndices=1:B.NodeCount; 45 | %P.SourcesNodeIndices=[3 10]; 46 | %P.SourcesNodeIndices=89; 47 | 48 | %AFFECTING FLOWS 49 | P.Diameters=B.LinkDiameter; 50 | P.Lengths=B.LinkLength; 51 | P.Roughness=B.LinkRoughnessCoeff; 52 | P.Elevation=B.NodeElevations; 53 | P.BaseDemand=B.NodeBaseDemands{1}; 54 | %P.SourcesNodeIndicesNonZero=P.BaseDemand~=0; 55 | P.NodesNonZeroDemands=find(P.BaseDemand>0); 56 | P.Patterns=B.Pattern; 57 | 58 | P.FlowParameters={'Diameters', 'Lengths','Roughness',... 59 | 'Elevation','BaseDemand','Patterns'}; 60 | P.FlowValues={P.Diameters, P.Lengths, P.Roughness,... 61 | P.Elevation, P.BaseDemand, P.Patterns}; 62 | P.FlowPrc={0,0,0,0,0,5}; 63 | P.FlowSamples={1,1,1,1,1,1}; 64 | end -------------------------------------------------------------------------------- /SPLACE/MISC/paretofront.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright (c) 2009, Yi Cao 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | %} 27 | 28 | function [] = paretofront(varargin) 29 | % PARETOFRONT returns the logical Pareto Front of a set of points. 30 | % 31 | % synopsis: front = paretofront(M) 32 | % 33 | % 34 | % INPUT ARGUMENT 35 | % 36 | % - M n x m array, of which (i,j) element is the j-th objective 37 | % value of the i-th point; 38 | % 39 | % OUTPUT ARGUMENT 40 | % 41 | % - front n x 1 logical vector to indicate if the corresponding 42 | % points are belong to the front (true) or not (false). 43 | % 44 | % By Yi Cao at Cranfield University, 31 October 2007 45 | % 46 | % Example 1: Find the Pareto Front of a circumference 47 | % 48 | % alpha = [0:.1:2*pi]'; 49 | % x = cos(alpha); 50 | % y = sin(alpha); 51 | % front = paretofront([x y]); 52 | % 53 | % hold on; 54 | % plot(x,y); 55 | % plot(x(front), y(front) , 'r'); 56 | % hold off 57 | % grid on 58 | % xlabel('x'); 59 | % ylabel('y'); 60 | % title('Pareto Front of a circumference'); 61 | % 62 | % Example 2: Find the Pareto Front of a set of 3D random points 63 | % X = rand(100,3); 64 | % front = paretofront(X); 65 | % 66 | % hold on; 67 | % plot3(X(:,1),X(:,2),X(:,3),'.'); 68 | % plot3(X(front, 1) , X(front, 2) , X(front, 3) , 'r.'); 69 | % hold off 70 | % grid on 71 | % view(-37.5, 30) 72 | % xlabel('X_1'); 73 | % ylabel('X_2'); 74 | % zlabel('X_3'); 75 | % title('Pareto Front of a set of random points in 3D'); 76 | % 77 | % 78 | % Example 3: Find the Pareto set of a set of 1000000 random points in 4D 79 | % The machine performing the calculations was a 80 | % Intel(R) Core(TM)2 CPU T2500 @ 2.0GHz, 2.0 GB of RAM 81 | % 82 | % X = rand(1000000,4); 83 | % t = cputime; 84 | % paretofront(X); 85 | % cputime - t 86 | % 87 | % ans = 88 | % 89 | % 1.473529 90 | 91 | error('mex file absent, type ''mex paretofront.c'' to compile'); 92 | -------------------------------------------------------------------------------- /SPLACE/SCENARIOS/GridParameters/gridmethod.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function [P,B]=gridmethod(varargin) 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | if isstruct(varargin{1}) 18 | P=GetGuiParameters(varargin{1}); 19 | B=varargin{1}.B; 20 | else 21 | P=DefaultParameters(varargin{1}); 22 | B=varargin{1}; 23 | end 24 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 25 | 26 | FlowScenarioSets={}; 27 | ContamScenarioSets={}; 28 | 29 | %compute scenarios affecting flows 30 | for i=1:length(P.FlowParameters) 31 | P.FlowParamScenarios{i}=linspaceNDim((P.FlowValues{i}-(P.FlowPrc{i}/100).*P.FlowValues{i})', (P.FlowValues{i}+(P.FlowPrc{i}/100).*P.FlowValues{i})', P.FlowSamples{i}); 32 | if find(strcmp(P.FlowParameters{i},'Patterns')) 33 | if (size(P.Patterns,1)==1) 34 | FlowScenarioSets{i}=1:size(P.FlowParamScenarios{i},2); 35 | else 36 | FlowScenarioSets{i}=1:size(P.FlowParamScenarios{i},3); 37 | end 38 | else 39 | FlowScenarioSets{i}=1:size(P.FlowParamScenarios{i},2); 40 | end 41 | end 42 | %compute scenarios affecting contamination sources 43 | for i=1:length(P.SourceParameters) 44 | P.SourceParamScenarios{i}=linspaceNDim((P.SourceValues{i}-(P.SourcePrc{i}/100).*P.SourceValues{i})', (P.SourceValues{i}+(P.SourcePrc{i}/100).*P.SourceValues{i})', P.SourceSamples{i}); 45 | ContamScenarioSets{i}=1:size(P.SourceParamScenarios{i},1); 46 | end 47 | %compute all source locations 48 | k=1; 49 | for i=1:P.SourcesMaxNumber 50 | tmp=combnk(P.SourcesNodeIndices,i); 51 | for j=1:size(tmp,1) 52 | T(k)={tmp(j,:)}; 53 | k=k+1; 54 | end 55 | end 56 | P.SourceLocationScenarios=T; 57 | ContamScenarioSets{size(ContamScenarioSets,2)+1}=1:size(P.SourceLocationScenarios,2); 58 | 59 | tmpsteps=(P.SourcesInjectionTimes(2)-P.SourcesInjectionTimes(1))*3600/P.PatternTimeStep; 60 | psim=double(P.SimulationTime); 61 | pts=double(P.PatternTimeStep); 62 | P.SourceTimes=min(find(pts/3600*(0:(psim-(pts/3600)))>=P.SourcesInjectionTimes(1))):max(find(pts/3600*(0:(psim-(pts/3600)))<=P.SourcesInjectionTimes(2))); 63 | ContamScenarioSets{size(ContamScenarioSets,2)+1}=1:length(P.SourceTimes); 64 | 65 | P.FlowScenarioSets=FlowScenarioSets; 66 | P.ContamScenarioSets=ContamScenarioSets; 67 | P.ScenariosFlowIndex=cartesianProduct(FlowScenarioSets); 68 | P.ScenariosContamIndex=cartesianProduct(ContamScenarioSets); 69 | P.TotalScenarios=size(P.ScenariosFlowIndex,1)*size(P.ScenariosContamIndex,1); 70 | P.newTotalofScenarios=P.TotalScenarios; 71 | if ~isstruct(varargin{1}) 72 | file0='file0'; 73 | save([pwd,'\RESULTS\',file0,'.0'],'P','B','-mat'); 74 | end 75 | end 76 | -------------------------------------------------------------------------------- /SPLACE/OPTIMIZATION/Exhaustive/ExhaustiveOptimization.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function ExhaustiveOptimization(varargin) 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | if isstruct(varargin{1}) 18 | file0=varargin{1}.file0; 19 | numberOfSensors=str2num(varargin{1}.pp.numberOfSensors); 20 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 21 | else 22 | file0=varargin{1}; 23 | numberOfSensors=varargin{2};% numberOfSensors=1:5; 24 | pathname=[pwd,'\RESULTS\']; 25 | end 26 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 27 | load([pathname,file0,'.0'],'-mat'); 28 | load([pathname,file0,'.w'],'-mat'); 29 | 30 | disp('Solve Sensor Placement') 31 | 32 | F1=[]; 33 | F2=[]; 34 | k=1; 35 | Y.x=[]; 36 | Y.F=[]; 37 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 38 | if isstruct(varargin{1}) 39 | progressbar('Solve with exhaustive method..') 40 | 41 | for j=numberOfSensors 42 | total(j) = nchoosek(length(1:B.NodeCount),j); 43 | end 44 | total=sum(total);pp=1; 45 | end 46 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 47 | for j=numberOfSensors 48 | numberCombinations=nchoosek(length(1:B.NodeCount),j); 49 | population=combnk(find(P.SensingNodeIndices),j); 50 | score=inf*ones(size(population,1),2); 51 | for i=1:size(population,1) 52 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 53 | if isstruct(varargin{1}) 54 | nload=pp/total; 55 | progressbar(nload); 56 | pp=pp+1; 57 | end 58 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 59 | score(i,:) = multiobjectiveFunctions(population(i,:),W); 60 | end 61 | PS{j}=paretofront(score); 62 | 63 | %because the pareto front does not return solutions with 64 | %the same values 65 | tmp=find(PS{j}==1); 66 | for l=1:length(tmp) 67 | for ll=2:size(population,1) 68 | if sum((score(tmp(l),:)-score(ll,:)).^2)<10^-20 69 | PS{j}(ll)=1; 70 | end 71 | end 72 | end 73 | sols=find(PS{j}==1); 74 | Y.xIndex{k}=population(sols,:); 75 | for i=1:size(Y.xIndex{k},1) 76 | x=logical(zeros(1,B.NodeCount)); 77 | x(Y.xIndex{k}(i,:))=1; 78 | Y.x=[Y.x; x]; 79 | end 80 | y=[j*ones(size(score,1),1) score]; 81 | Y.F=[Y.F; y(sols,:)]; 82 | k=k+1; 83 | end 84 | save([pathname,file0,'.y0'],'Y', '-mat'); 85 | 86 | if isstruct(varargin{1}) 87 | progressbar(1); 88 | end 89 | disp('Run was succesfull.') 90 | %%%%%%%%%%%%%%%% 91 | end 92 | 93 | function f = multiobjectiveFunctions(x,W) 94 | x=(round(x)); 95 | if sum(x)~=0 96 | f(1)=mean(min(W{1}(:,x),[],2)); 97 | f(2)=max(min(W{1}(:,x),[],2)); 98 | else 99 | f=[inf inf]; 100 | end 101 | end 102 | -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/32bit/epanetmsx.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** MODULE: EPANETMSX.H 3 | ** PROJECT: EPANET-MSX 4 | ** DESCRIPTION: C/C++ header file for EPANET Multi-Species Extension Toolkit 5 | ** COPYRIGHT: Copyright (C) 2007 Feng Shang, Lewis Rossman, and James Uber. 6 | ** All Rights Reserved. See license information in LICENSE.TXT. 7 | ** AUTHORS: L. Rossman, US EPA - NRMRL 8 | ** F. Shang, University of Cincinnati 9 | ** J. Uber, University of Cincinnati 10 | ** VERSION: 1.1 11 | ** LAST UPDATE: 11/01/10 12 | *******************************************************************************/ 13 | 14 | #ifndef EPANETMSX_H 15 | #define EPANETMSX_H 16 | 17 | // --- define WINDOWS 18 | 19 | #undef WINDOWS 20 | #ifdef _WIN32 21 | #define WINDOWS 22 | #endif 23 | #ifdef __WIN32__ 24 | #define WINDOWS 25 | #endif 26 | 27 | // --- define DLLEXPORT 28 | 29 | #ifndef DLLEXPORT // ttaxon - 9/7/10 30 | #ifdef WINDOWS 31 | #ifdef __cplusplus 32 | #define DLLEXPORT extern "C" __declspec(dllexport) __stdcall 33 | #else 34 | #define DLLEXPORT __declspec(dllexport) __stdcall 35 | #endif 36 | #else 37 | #ifdef __cplusplus 38 | #define DLLEXPORT extern "C" 39 | #else 40 | #define DLLEXPORT 41 | #endif 42 | #endif 43 | #endif 44 | 45 | // --- define MSX constants 46 | 47 | #define MSX_NODE 0 48 | #define MSX_LINK 1 49 | #define MSX_TANK 2 50 | #define MSX_SPECIES 3 51 | #define MSX_TERM 4 52 | #define MSX_PARAMETER 5 53 | #define MSX_CONSTANT 6 54 | #define MSX_PATTERN 7 55 | 56 | #define MSX_BULK 0 57 | #define MSX_WALL 1 58 | 59 | #define MSX_NOSOURCE -1 60 | #define MSX_CONCEN 0 61 | #define MSX_MASS 1 62 | #define MSX_SETPOINT 2 63 | #define MSX_FLOWPACED 3 64 | 65 | // --- declare MSX functions 66 | 67 | int DLLEXPORT MSXopen(char *fname); 68 | int DLLEXPORT MSXsolveH(void); 69 | int DLLEXPORT MSXusehydfile(char *fname); 70 | int DLLEXPORT MSXsolveQ(void); 71 | int DLLEXPORT MSXinit(int saveFlag); 72 | int DLLEXPORT MSXstep(long *t, long *tleft); 73 | int DLLEXPORT MSXsaveoutfile(char *fname); 74 | int DLLEXPORT MSXsavemsxfile(char *fname); 75 | int DLLEXPORT MSXreport(void); 76 | int DLLEXPORT MSXclose(void); 77 | 78 | int DLLEXPORT MSXgetindex(int type, char *id, int *index); 79 | int DLLEXPORT MSXgetIDlen(int type, int index, int *len); 80 | int DLLEXPORT MSXgetID(int type, int index, char *id, int len); 81 | int DLLEXPORT MSXgetcount(int type, int *count); 82 | int DLLEXPORT MSXgetspecies(int index, int *type, char *units, double *aTol, 83 | double *rTol); 84 | int DLLEXPORT MSXgetconstant(int index, double *value); 85 | int DLLEXPORT MSXgetparameter(int type, int index, int param, double *value); 86 | int DLLEXPORT MSXgetsource(int node, int species, int *type, double *level, 87 | int *pat); 88 | int DLLEXPORT MSXgetpatternlen(int pat, int *len); 89 | int DLLEXPORT MSXgetpatternvalue(int pat, int period, double *value); 90 | int DLLEXPORT MSXgetinitqual(int type, int index, int species, double *value); 91 | int DLLEXPORT MSXgetqual(int type, int index, int species, double *value); 92 | int DLLEXPORT MSXgeterror(int code, char *msg, int len); 93 | 94 | int DLLEXPORT MSXsetconstant(int index, double value); 95 | int DLLEXPORT MSXsetparameter(int type, int index, int param, double value); 96 | int DLLEXPORT MSXsetinitqual(int type, int index, int species, double value); 97 | int DLLEXPORT MSXsetsource(int node, int species, int type, double level, 98 | int pat); 99 | int DLLEXPORT MSXsetpatternvalue(int pat, int period, double value); 100 | int DLLEXPORT MSXsetpattern(int pat, double mult[], int len); 101 | int DLLEXPORT MSXaddpattern(char *id); 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /EPANET-MATLAB-Toolkit/64bit/epanetmsx.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | ** MODULE: EPANETMSX.H 3 | ** PROJECT: EPANET-MSX 4 | ** DESCRIPTION: C/C++ header file for EPANET Multi-Species Extension Toolkit 5 | ** COPYRIGHT: Copyright (C) 2007 Feng Shang, Lewis Rossman, and James Uber. 6 | ** All Rights Reserved. See license information in LICENSE.TXT. 7 | ** AUTHORS: L. Rossman, US EPA - NRMRL 8 | ** F. Shang, University of Cincinnati 9 | ** J. Uber, University of Cincinnati 10 | ** VERSION: 1.1 11 | ** LAST UPDATE: 11/01/10 12 | *******************************************************************************/ 13 | 14 | #ifndef EPANETMSX_H 15 | #define EPANETMSX_H 16 | 17 | // --- define WINDOWS 18 | 19 | #undef WINDOWS 20 | #ifdef _WIN32 21 | #define WINDOWS 22 | #endif 23 | #ifdef __WIN32__ 24 | #define WINDOWS 25 | #endif 26 | 27 | // --- define DLLEXPORT 28 | 29 | #ifndef DLLEXPORT // ttaxon - 9/7/10 30 | #ifdef WINDOWS 31 | #ifdef __cplusplus 32 | #define DLLEXPORT extern "C" __declspec(dllexport) __stdcall 33 | #else 34 | #define DLLEXPORT __declspec(dllexport) __stdcall 35 | #endif 36 | #else 37 | #ifdef __cplusplus 38 | #define DLLEXPORT extern "C" 39 | #else 40 | #define DLLEXPORT 41 | #endif 42 | #endif 43 | #endif 44 | 45 | // --- define MSX constants 46 | 47 | #define MSX_NODE 0 48 | #define MSX_LINK 1 49 | #define MSX_TANK 2 50 | #define MSX_SPECIES 3 51 | #define MSX_TERM 4 52 | #define MSX_PARAMETER 5 53 | #define MSX_CONSTANT 6 54 | #define MSX_PATTERN 7 55 | 56 | #define MSX_BULK 0 57 | #define MSX_WALL 1 58 | 59 | #define MSX_NOSOURCE -1 60 | #define MSX_CONCEN 0 61 | #define MSX_MASS 1 62 | #define MSX_SETPOINT 2 63 | #define MSX_FLOWPACED 3 64 | 65 | // --- declare MSX functions 66 | 67 | int DLLEXPORT MSXopen(char *fname); 68 | int DLLEXPORT MSXsolveH(void); 69 | int DLLEXPORT MSXusehydfile(char *fname); 70 | int DLLEXPORT MSXsolveQ(void); 71 | int DLLEXPORT MSXinit(int saveFlag); 72 | int DLLEXPORT MSXstep(long *t, long *tleft); 73 | int DLLEXPORT MSXsaveoutfile(char *fname); 74 | int DLLEXPORT MSXsavemsxfile(char *fname); 75 | int DLLEXPORT MSXreport(void); 76 | int DLLEXPORT MSXclose(void); 77 | 78 | int DLLEXPORT MSXgetindex(int type, char *id, int *index); 79 | int DLLEXPORT MSXgetIDlen(int type, int index, int *len); 80 | int DLLEXPORT MSXgetID(int type, int index, char *id, int len); 81 | int DLLEXPORT MSXgetcount(int type, int *count); 82 | int DLLEXPORT MSXgetspecies(int index, int *type, char *units, double *aTol, 83 | double *rTol); 84 | int DLLEXPORT MSXgetconstant(int index, double *value); 85 | int DLLEXPORT MSXgetparameter(int type, int index, int param, double *value); 86 | int DLLEXPORT MSXgetsource(int node, int species, int *type, double *level, 87 | int *pat); 88 | int DLLEXPORT MSXgetpatternlen(int pat, int *len); 89 | int DLLEXPORT MSXgetpatternvalue(int pat, int period, double *value); 90 | int DLLEXPORT MSXgetinitqual(int type, int index, int species, double *value); 91 | int DLLEXPORT MSXgetqual(int type, int index, int species, double *value); 92 | int DLLEXPORT MSXgeterror(int code, char *msg, int len); 93 | 94 | int DLLEXPORT MSXsetconstant(int index, double value); 95 | int DLLEXPORT MSXsetparameter(int type, int index, int param, double value); 96 | int DLLEXPORT MSXsetinitqual(int type, int index, int species, double value); 97 | int DLLEXPORT MSXsetsource(int node, int species, int type, double level, 98 | int pat); 99 | int DLLEXPORT MSXsetpatternvalue(int pat, int period, double value); 100 | int DLLEXPORT MSXsetpattern(int pat, double mult[], int len); 101 | int DLLEXPORT MSXaddpattern(char *id); 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /SPLACE/OPTIMIZATION/Evolutionary/EvolutionaryOptimization.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function EvolutionaryOptimization(varargin) 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | if isstruct(varargin{1}) 18 | file0=varargin{1}.file0; 19 | PopulationSize_Data=varargin{1}.pp.PopulationSize_Data; 20 | ParetoFraction_Data=varargin{1}.pp.ParetoFraction_Data; 21 | Generations_Data=varargin{1}.pp.Generations_Data; 22 | numberOfSensors=str2num(varargin{1}.pp.numberOfSensors); 23 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 24 | else 25 | file0=varargin{1}; 26 | PopulationSize_Data=1000; 27 | ParetoFraction_Data=0.7; 28 | Generations_Data=100; 29 | numberOfSensors=1:5; 30 | pathname=[pwd,'\RESULTS\']; 31 | end 32 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 33 | load([pathname,file0,'.0'],'-mat'); 34 | load([pathname,file0,'.w'],'-mat'); 35 | 36 | if exist('gamultiobj','file')==2 37 | Y.x=[]; 38 | Y.F=[];u=1; 39 | W{1}=W{1}(:,find(P.SensingNodeIndices)); 40 | for i=numberOfSensors 41 | %[x,fval,exitflag,output,population,score]=multiObjectiveOptimization(W,length(numberOfSensors),PopulationSize_Data,ParetoFraction_Data,Generations_Data); 42 | [x,fval,exitflag,output,population,score]=multiObjectiveOptimization(... 43 | W,i,PopulationSize_Data,ParetoFraction_Data,Generations_Data); 44 | [xIdx tmp]=unique(sort(round(x),2),'rows'); 45 | fval=fval(tmp,:); 46 | 47 | a=find(P.SensingNodeIndices); 48 | Y.xIndex{u}=a(xIdx); 49 | 50 | % Y.xIndex{u}=xIdx; 51 | for j=1:size(xIdx,1) 52 | zer=logical(zeros(1,B.NodeCount)); 53 | zer(xIdx(j,:))=1; 54 | Y.x(size(Y.x,1)+1,:)=zer; 55 | Y.F(size(Y.F,1)+1,:)=[i,fval(j,:)]; 56 | end 57 | u=u+1; 58 | end 59 | save([pathname,file0,'.y1'],'Y', '-mat'); 60 | else 61 | disp('GAMULTIOBJ is not currenty installed in MATLAB') 62 | end 63 | 64 | end 65 | 66 | 67 | function [x,fval,exitflag,output,population,score] = multiObjectiveOptimization(W,nvars,PopulationSize_Data,ParetoFraction_Data,Generations_Data) 68 | % This is an auto generated M-file from Optimization Tool. 69 | % Start with the default options 70 | options = gaoptimset; 71 | % Modify options setting 72 | %options = gaoptimset(options,'PopulationType', 'bitstring'); 73 | options = gaoptimset(options,'PopulationSize', PopulationSize_Data); 74 | options = gaoptimset(options,'ParetoFraction', ParetoFraction_Data); 75 | options = gaoptimset(options,'Generations', Generations_Data); 76 | options = gaoptimset(options,'CreationFcn', @gacreationuniform); 77 | options = gaoptimset(options,'CrossoverFcn', @crossoverscattered); 78 | options = gaoptimset(options,'MutationFcn', @mutationadaptfeasible); 79 | options = gaoptimset(options,'Display', 'iter'); 80 | options = gaoptimset(options,'PlotFcns', { @gaplotpareto }); 81 | options = gaoptimset(options,'OutputFcns', { [] }); 82 | lb=ones(1,nvars); 83 | ub=size(W{1},2).*ones(1,nvars); 84 | [x,fval,exitflag,output,population,score] = ... 85 | gamultiobj(@(x)multiobjectiveFunctions(x,W),nvars,[],[],[],[],lb,ub,options); 86 | end 87 | 88 | function f = multiobjectiveFunctions(x,W) 89 | x=(round(x)); 90 | if sum(x)~=0 91 | f(1)=mean(min(W{1}(:,x),[],2)); 92 | f(2)=max(min(W{1}(:,x),[],2)); 93 | else 94 | f=[inf inf]; 95 | end 96 | end -------------------------------------------------------------------------------- /SPLACE/SCENARIOS/GridParameters/GetGuiParameters.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function P=GetGuiParameters(varargin) 16 | % varargin{1}...handles. 17 | B=varargin{1}.B; 18 | 19 | % Time Parameters 20 | P.SimulationTime = str2num(get(varargin{1}.SimulationTime,'String')); 21 | P.PatternTimeStep = str2num(get(varargin{1}.PatternTimeStep,'String')); 22 | 23 | % CONTAMINANT (A) 24 | P.SourcePrc={}; 25 | P.SourceSamples={}; 26 | P.SourceInjectionRate = str2num(get(varargin{1}.SourceInjectionRate,'String')); 27 | P.SourceDuration = str2num(get(varargin{1}.SourceDuration,'String')); 28 | P.SourcePrc{1} = str2double(get(varargin{1}.SourcePrcInj,'String')); 29 | P.SourceSamples{1} = str2double(get(varargin{1}.SourceSamplesInj,'String')); 30 | P.SourcePrc{2} = str2double(get(varargin{1}.SourcePrcDuration,'String')); 31 | P.SourceSamples{2} = str2double(get(varargin{1}.SourceSamplesDuration,'String')); 32 | P.SourceParameters={'SourceInjectionRate','SourceDuration'}; 33 | P.SourceValues={P.SourceInjectionRate, P.SourceDuration}; 34 | 35 | % CONTAMINANT (B) 36 | v=get(varargin{1}.SourcesMaxNumber1,'Value'); %maximum number of simultaneous sources (including 1,2..) 37 | if v==1 38 | P.SourcesMaxNumber=1; 39 | else 40 | P.SourcesMaxNumber=2; 41 | end 42 | 43 | P.SourcesInjectionTimes(1)=str2num(get(varargin{1}.start,'String')); 44 | P.SourcesInjectionTimes(2)=str2num(get(varargin{1}.stop,'String')); 45 | 46 | % Reslease Location 47 | % P.SourcesNodeIndices=find(varargin{1}.release); 48 | P.SourcesNodeIndices(1:B.NodeCount)=0; 49 | for i=1:varargin{1}.B.NodeCount 50 | P.SourcesNodeIndices(i)=varargin{1}.release(i); 51 | if P.SourcesNodeIndices(i)~=0 52 | P.SourcesNodeIndices(i)=i;%u=u+1; 53 | end 54 | end 55 | % Sensing Location 56 | % P.SensingNodeIndices=find(varargin{1}.sensing); 57 | P.SensingNodeIndices(1:B.NodeCount)=0; 58 | for i=1:varargin{1}.B.NodeCount 59 | P.SensingNodeIndices(i)=varargin{1}.sensing(i); 60 | if P.SensingNodeIndices(i)~=0 61 | P.SensingNodeIndices(i)=i;%u=u+1; 62 | end 63 | end 64 | 65 | % Hydraulic Parameters 66 | 67 | % Links 68 | % Diameters 69 | LinkTable=get(varargin{1}.LinkTable,'data'); 70 | P.FlowPrc={}; 71 | P.FlowSamples={}; 72 | 73 | P.FlowPrc{1}=LinkTable(1,1); 74 | P.FlowSamples{1}=LinkTable(1,2); 75 | P.Diameters=LinkTable(1,3:end); 76 | % Lengths 77 | P.FlowPrc{2}=LinkTable(2,1); 78 | P.FlowSamples{2}=LinkTable(2,2); 79 | P.Lengths=LinkTable(2,3:end); 80 | % Roughness 81 | P.FlowPrc{3}=LinkTable(3,1); 82 | P.FlowSamples{3}=LinkTable(3,2); 83 | P.Roughness=LinkTable(3,3:end); 84 | 85 | % Nodes 86 | % Elevations 87 | NodeTable=get(varargin{1}.NodeTable,'data'); 88 | P.FlowPrc{4}=NodeTable(1,1); 89 | P.FlowSamples{4}=NodeTable(1,2); 90 | P.Elevation=NodeTable(1,3:end); 91 | % Basedemands 92 | P.FlowPrc{5}=NodeTable(2,1); 93 | P.FlowSamples{5}=NodeTable(2,2); 94 | P.BaseDemand=NodeTable(2,3:end); 95 | % Patterns 96 | P.Patterns=B.getPattern; 97 | P.FlowPrc{6}=str2double(get(varargin{1}.FlowPrcPatterns,'String')); 98 | P.FlowSamples{6} = str2double(get(varargin{1}.FlowSamplesPatterns,'String')); 99 | 100 | P.FlowParameters={'Diameters', 'Lengths','Roughness',... 101 | 'Elevation','BaseDemand','Patterns'}; 102 | P.FlowValues={P.Diameters, P.Lengths, P.Roughness,... 103 | P.Elevation, P.BaseDemand, P.Patterns}; 104 | end -------------------------------------------------------------------------------- /SPLACE/MISC/paretofront.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009, Yi Cao 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | 29 | #include 30 | #include "mex.h" 31 | 32 | 33 | /* 34 | paretomember returns the logical Pareto membership of a set of points. 35 | 36 | synopsis: front = paretofront(objMat) 37 | 38 | created by Yi Cao 39 | 40 | y.cao@cranfield.ac.uk 41 | 42 | for compiling type 43 | 44 | mex paretofront.c 45 | 46 | */ 47 | 48 | 49 | void paretofront(bool * front, double * M, unsigned int row, unsigned int col); 50 | 51 | void mexFunction( int nlhs, mxArray *plhs[] , int nrhs, const mxArray *prhs[] ) 52 | { 53 | bool * front; 54 | double * M; 55 | unsigned int row, col; 56 | const int *dims; 57 | 58 | if(nrhs == 0 || nlhs > 1) 59 | { 60 | printf("\nsynopsis: front = paretofront(X)"); 61 | plhs[0] = mxCreateDoubleMatrix(0 , 0 , mxREAL); 62 | return; 63 | } 64 | 65 | M = mxGetPr(prhs[0]); 66 | dims = mxGetDimensions(prhs[0]); 67 | row = dims[0]; 68 | col = dims[1]; 69 | 70 | 71 | 72 | /* ----- output ----- */ 73 | 74 | plhs[0] = mxCreateLogicalMatrix (row , 1); 75 | front = (bool *) mxGetPr(plhs[0]); 76 | 77 | 78 | /* main call */ 79 | paretofront(front, M, row, col); 80 | } 81 | 82 | void paretofront(bool * front, double * M, unsigned int row, unsigned int col) 83 | { 84 | unsigned int t,s,i,j,j1,j2; 85 | bool *checklist, coldominatedflag; 86 | 87 | checklist = (bool *)mxMalloc(row*sizeof(bool)); 88 | for(t = 0; t M[j2]) { 107 | coldominatedflag=true; 108 | break; 109 | } 110 | } 111 | if (!coldominatedflag) { //swap active index continue checking 112 | front[t]=false; 113 | checklist[i]=false; 114 | coldominatedflag=true; 115 | t=i; 116 | } 117 | } 118 | front[t]=coldominatedflag; 119 | if (t>s) { 120 | for (i=s+1; iIM{1}.SensorThreshold))=1; 75 | detectionNodes=find(sum(c1)); 76 | cwv = c1.*Dt.*demand{d(k)}; %D{d(k)}.Demand.*Dt; 77 | for j=detectionNodes 78 | [~, tmp] = max(c1(:,j)); 79 | W{1}(l,j) = sum(sum(cwv(1:tmp,1:B.NodeJunctionCount)));%B.NodeCount 80 | end 81 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 82 | if isstruct(varargin{1}) 83 | nload=pp/(totalscenarios); 84 | progressbar(nload) 85 | pp=pp+1; 86 | end 87 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 88 | try 89 | W{1}(l,find(W{1}(l,:) == inf)) = sum(sum(cwv(1:size(cwv,1),1:B.NodeJunctionCount))); 90 | catch 91 | end 92 | end 93 | clear C; 94 | W{1}(:,P.SensingNodeIndices==0) = 0; 95 | save([pathname,file0,'.w'],'W', 'IM', '-mat'); 96 | end 97 | end 98 | if isstruct(varargin{1}) 99 | progressbar(1); 100 | end 101 | disp('Run was succesfull.') 102 | end -------------------------------------------------------------------------------- /SPLACE/MISC/linspaceNDim.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright (c) 2009, Steeve AMBROISE 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in 13 | the documentation and/or other materials provided with the distribution 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | %} 27 | 28 | function y = linspaceNDim(d1, d2, n) 29 | %LINSPACENDIM Linearly spaced multidimensional matrix. 30 | % LINSPACENDIM(d1, d2) generates a multi-dimensional 31 | % matrix of 100 linearly equally spaced points between 32 | % each element of matrices d1 and d2. 33 | % 34 | % LINSPACENDIM(d1, d2, N) generates N points between 35 | % each element of matrices X1 and X2. 36 | % 37 | % Example: 38 | % d1 = rand(3, 2, 4); d2 = rand(size(d1)); n = 1; 39 | % 40 | % y = linspaceNDim(d1, d2, n) returns a multidimensional matrix y of 41 | % size (2, 4, 3, 10) 42 | % 43 | % 44 | % Class support for inputs X1,X2: 45 | % float: Multidimensional matrix, vector, double, single 46 | % 47 | % Steeve AMBROISE --> sambroise@gmail.com 48 | % 49 | % $ Date: 2009/01/29 21:00:00 GMT $ 50 | % $ revised Date: 2009/02/02 18:00:00 GMT $ 51 | % Bug fixed for singleton dimensions that occur when d1 or d2 52 | % are empty matrix, scalar or vector. 53 | % 54 | % 55 | if nargin == 2 56 | n = 100; 57 | end 58 | n = double(n); 59 | d1 = squeeze(d1); d2 = squeeze(d2); 60 | if ndims(d1)~= ndims(d2) || any(size(d1)~= size(d2)) 61 | error('d1 and d2 must have the same number of dimension and the same size'), 62 | end 63 | NDim = ndims(d1); 64 | %%%%%%%% To know if the two first dimensions are singleton dimensions 65 | if NDim==2 && any(size(d1)==1) 66 | NDim = NDim-1; 67 | if all(size(d1)==1) 68 | NDim = 0; 69 | end 70 | end 71 | pp = (0:n-2)./(floor(n)-1); 72 | Sum1 = TensorProduct(d1, ones(1,n-1)); 73 | Sum2 = TensorProduct((d2-d1), pp); 74 | y = cat(NDim+1, Sum1 + Sum2, shiftdim(d2, size(d1, 1)==1 )); 75 | %%%%% An old function that I wrote to replace the built in Matlab function: 76 | %%%%% KRON 77 | 78 | end 79 | 80 | function Z = TensorProduct(X,Y) 81 | % Z = TensorProduct(X,Y) returns the REAL Kronecker tensor product of X and Y. 82 | % The result is a multidimensional array formed by taking all possible products 83 | % between the elements of X and those of Y. 84 | % 85 | % If X is m-by-n and Y is p-by-q-by-r, then kron(X,Y) 86 | % is m-by-p-by-n-by-q-by-r. 87 | % 88 | % X and Y are multidimensional matrices 89 | % of any size and number of dimensions 90 | % 91 | % E.g. if X is of dimensions (4, 5, 3) and Y of dimension (3, 1, 7, 4) 92 | % TensorProduct(X, Y) returns a multidimensional matrix Z of dimensions: 93 | % (4, 5, 3, 3, 7, 4) 94 | % 95 | % $ Date: 2001/11/09 10:20:00 GMT $ 96 | % 97 | % Steeve AMBROISE --> sambroise@gmail.com 98 | % 99 | 100 | sX=size(X);sY=size(Y); 101 | 102 | ndim1=ndims(X);ndim2=ndims(Y); 103 | 104 | indperm=[ndim2+1:ndim1+ndim2,1:ndim2]; 105 | 106 | % to remove all singleton dimensions 107 | Z=squeeze(repmat(X,[ones(1,ndims(X)),sY]).*... 108 | permute(repmat(Y,[ones(1,ndims(Y)),sX]),indperm)); 109 | end 110 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | [![DOI](https://zenodo.org/badge/DOI/10.1016/j.proeng.2014.02.066.svg)](https://doi.org/10.1016/j.proeng.2014.02.066) 4 | 5 | [![View splace-toolkit on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://www.mathworks.com/matlabcentral/fileexchange/129839-splace-toolkit) 6 | 7 | Sensor Placement (S-PLACE) Toolkit 8 | ============== 9 | 10 | 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 build 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. 11 | 12 | ## Table of Contents 13 | 14 | - [How to cite](#how-to-cite) 15 | - [Requirements](#requirements) 16 | - [Licenses](#Licenses) 17 | - [EPANET](#EPANET) 18 | - [Instructions](#Instructions) 19 | 20 | ## How to cite 21 | 22 | ``` 23 | @proceedings{eliades_demetrios_g_2014_1252756, 24 | title = {{Sensor Placement in Water Distribution Systems 25 | Using the S-PLACE Toolkit}}, 26 | year = 2014, 27 | publisher = {Zenodo}, 28 | month = apr, 29 | doi = {10.1016/j.proeng.2014.02.066}, 30 | url = {https://doi.org/10.1016/j.proeng.2014.02.066} 31 | } 32 | ``` 33 | 34 | * 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) 35 | 36 | Mathematical Framework 37 | * Eliades, D., Polycarpou, M., 2010. A fault diagnosis and security framework for water systems. IEEE Transactions on Control Systems Technology 38 | 18, 1254�1265. [ref](http://ieeexplore.ieee.org/xpl/articleDetails.jsp?tp=&arnumber=5350461) 39 | 40 | ↑ [Back to top](#table-of-contents) 41 | 42 | ## Requirements 43 | 44 | * [Matlab](http://www.mathworks.com/) 45 | * [EPANET v2.1](https://github.com/OpenWaterAnalytics/EPANET) 46 | 47 | ↑ [Back to top](#table-of-contents) 48 | 49 | ## Licenses 50 | 51 | S-PLACE Toolkit 52 | 53 | 54 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 55 | 56 | 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"); 57 | - You may not use this work except in compliance with the Licence. 58 | - You may obtain a copy of the Licence at: (http://ec.europa.eu/idabc/eupl) 59 | 60 | 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. 61 | 62 | See the Licence for the specific language governing permissions and limitations under the Licence. 63 | 64 | ↑ [Back to top](#table-of-contents) 65 | 66 | ## EPANET 67 | 68 | EPANET is public domain software that may be freely copied and distributed. 69 | 70 | ## Instructions 71 | 72 | The Toolkit works with your 32-bit Matlab version, and can work with 64-bit computers by using a suitable epanet.dll 73 | 74 | 1. To download, press here: https://github.com/KIOS-Research/splace-toolkit/archive/master.zip 75 | 76 | 2. Unzip this file in a folder, and set this folder as the "active" matlab path. 77 | 78 | 3. Next, you just run the SPLACE.m file. This will load the GUI. From there, you can load any *.inp files. 79 | 80 | 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. 81 | 82 | 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. 83 | 84 | ↑ [Back to top](#table-of-contents) 85 | -------------------------------------------------------------------------------- /SPLACE.prj: -------------------------------------------------------------------------------- 1 | 2 | 3 | SPLACE 4 | 5 | 6 | 1.0 7 | Marios Kyriakou 8 | mariosmsk@gmail.com 9 | KIOS Research and Innovation Center 10 | 11 | 12 | 13 | 14 | \KIOS Research and Innovation Center\SPLACE\ 15 | option.installpath.programfiles 16 | 17 | 18 | 19 | ${PROJECT_ROOT}\SPLACE\for_testing 20 | ${PROJECT_ROOT}\SPLACE\for_redistribution_files_only 21 | ${PROJECT_ROOT}\SPLACE\for_redistribution 22 | false 23 | 24 | true 25 | subtarget.standalone 26 | 27 | 28 | 35000 29 | 35010 30 | 31 | true 32 | false 33 | false 34 | MyAppInstaller_web 35 | MyAppInstaller_mcr 36 | MyAppInstaller_app 37 | true 38 | false 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | ${PROJECT_ROOT}\SPLACE.m 72 | 73 | 74 | 75 | 76 | ${PROJECT_ROOT}\SPLACE.fig 77 | 78 | 79 | C:\Users\mkiria01\Dropbox\splace-toolkit\SPLACE\for_testing\readme.txt 80 | C:\Users\mkiria01\Dropbox\splace-toolkit\SPLACE\for_testing\splash.png 81 | C:\Users\mkiria01\Dropbox\splace-toolkit\SPLACE\for_testing\SPLACE.exe 82 | 83 | 84 | 85 | C:\Program Files (x86)\MATLAB\R2015b 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | true 95 | 96 | 97 | 98 | 99 | true 100 | 101 | 102 | 103 | 104 | true 105 | 106 | 107 | 108 | 109 | true 110 | 111 | 112 | 113 | 114 | false 115 | false 116 | true 117 | false 118 | false 119 | false 120 | false 121 | false 122 | 6.1 123 | true 124 | false 125 | win32 126 | true 127 | 128 | 129 | -------------------------------------------------------------------------------- /HELP/about.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function varargout = about(varargin) 16 | % ABOUT MATLAB code for about.fig 17 | % ABOUT, by itself, creates a new ABOUT or raises the existing 18 | % singleton*. 19 | % 20 | % H = ABOUT returns the handle to a new ABOUT or the handle to 21 | % the existing singleton*. 22 | % 23 | % ABOUT('CALLBACK',hObject,eventData,handles,...) calls the local 24 | % function named CALLBACK in ABOUT.M with the given input arguments. 25 | % 26 | % ABOUT('Property','Value',...) creates a new ABOUT or raises the 27 | % existing singleton*. Starting from the left, property value pairs are 28 | % applied to the GUI before about_OpeningFcn gets called. An 29 | % unrecognized property name or invalid value makes property application 30 | % stop. All inputs are passed to about_OpeningFcn via varargin. 31 | % 32 | % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 33 | % instance to run (singleton)". 34 | % 35 | % See also: GUIDE, GUIDATA, GUIHANDLES 36 | 37 | % Edit the above text to modify the response to help about 38 | 39 | % Last Modified by GUIDE v2.5 27-May-2013 14:29:23 40 | 41 | % Begin initialization code - DO NOT EDIT 42 | gui_Singleton = 1; 43 | gui_State = struct('gui_Name', mfilename, ... 44 | 'gui_Singleton', gui_Singleton, ... 45 | 'gui_OpeningFcn', @about_OpeningFcn, ... 46 | 'gui_OutputFcn', @about_OutputFcn, ... 47 | 'gui_LayoutFcn', [] , ... 48 | 'gui_Callback', []); 49 | if nargin && ischar(varargin{1}) 50 | gui_State.gui_Callback = str2func(varargin{1}); 51 | end 52 | 53 | if nargout 54 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 55 | else 56 | gui_mainfcn(gui_State, varargin{:}); 57 | end 58 | % End initialization code - DO NOT EDIT 59 | 60 | 61 | % --- Executes just before about is made visible. 62 | function about_OpeningFcn(hObject, eventdata, handles, varargin) 63 | % This function has no output args, see OutputFcn. 64 | % hObject handle to figure 65 | % eventdata reserved - to be defined in a future version of MATLAB 66 | % handles structure with handles and user data (see GUIDATA) 67 | % varargin command line arguments to about (see VARARGIN) 68 | 69 | % Choose default command line output for about 70 | handles.output = hObject; 71 | 72 | % Update handles structure 73 | guidata(hObject, handles); 74 | 75 | % UIWAIT makes about wait for user response (see UIRESUME) 76 | % uiwait(handles.figure1); 77 | 78 | 79 | % --- Outputs from this function are returned to the command line. 80 | function varargout = about_OutputFcn(hObject, eventdata, handles) 81 | % varargout cell array for returning output args (see VARARGOUT); 82 | % hObject handle to figure 83 | % eventdata reserved - to be defined in a future version of MATLAB 84 | % handles structure with handles and user data (see GUIDATA) 85 | 86 | % Get default command line output from handles structure 87 | varargout{1} = handles.output; 88 | 89 | 90 | % --- Executes on button press in pushbutton1. 91 | function pushbutton1_Callback(hObject, eventdata, handles) 92 | % hObject handle to pushbutton1 (see GCBO) 93 | % eventdata reserved - to be defined in a future version of MATLAB 94 | % handles structure with handles and user data (see GUIDATA) 95 | web('http://www.kios.org.cy'); 96 | 97 | 98 | % --- Executes on button press in pushbutton2. 99 | function pushbutton2_Callback(hObject, eventdata, handles) 100 | % hObject handle to pushbutton2 (see GCBO) 101 | % eventdata reserved - to be defined in a future version of MATLAB 102 | % handles structure with handles and user data (see GUIDATA) 103 | web('http://www.ucy.ac.cy'); 104 | 105 | 106 | function edit1_Callback(hObject, eventdata, handles) 107 | % hObject handle to edit1 (see GCBO) 108 | % eventdata reserved - to be defined in a future version of MATLAB 109 | % handles structure with handles and user data (see GUIDATA) 110 | 111 | % Hints: get(hObject,'String') returns contents of edit1 as text 112 | % str2double(get(hObject,'String')) returns contents of edit1 as a double 113 | 114 | 115 | % --- Executes during object creation, after setting all properties. 116 | function edit1_CreateFcn(hObject, eventdata, handles) 117 | % hObject handle to edit1 (see GCBO) 118 | % eventdata reserved - to be defined in a future version of MATLAB 119 | % handles empty - handles not created until after all CreateFcns called 120 | 121 | % Hint: edit controls usually have a white background on Windows. 122 | % See ISPC and COMPUTER. 123 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 124 | set(hObject,'BackgroundColor','white'); 125 | end 126 | -------------------------------------------------------------------------------- /SPLACE/SIMULATE/SimulateAll/runMultipleScenarios.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function runMultipleScenarios(varargin) 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | if isstruct(varargin{1}) 18 | file0=varargin{1}.file0; 19 | T=varargin{1}.T; 20 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 21 | else 22 | file0=varargin{1}; 23 | T=100; %save every 1000 scenarios 24 | pathname=[pwd,'\RESULTS\']; 25 | end 26 | 27 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 28 | load([pathname,file0,'.0'],'-mat') 29 | B.setQualityType('chem','mg/L') 30 | 31 | B.setTimeSimulationDuration(P.SimulationTime*3600); 32 | % disp('Create Hydraulic files') 33 | for i=1:size(P.ScenariosFlowIndex,1) 34 | B.setLinkDiameter(P.FlowParamScenarios{1}(:, P.ScenariosFlowIndex(i,1))') 35 | B.setLinkLength(P.FlowParamScenarios{2}(:, P.ScenariosFlowIndex(i,2))') 36 | B.setLinkRoughnessCoeff(P.FlowParamScenarios{3}(:, P.ScenariosFlowIndex(i,3))') 37 | B.setNodeElevations(P.FlowParamScenarios{4}(:, P.ScenariosFlowIndex(i,4))') 38 | bs = P.FlowParamScenarios{5}(:, P.ScenariosFlowIndex(i,5))'; 39 | for n = 1:B.getNodeCount 40 | B.setNodeBaseDemands(n, bs(n)) 41 | end 42 | if size(P.Patterns,1)==1 43 | B.setPatternMatrix(P.FlowParamScenarios{6}(:,P.ScenariosFlowIndex(i,6))') 44 | else 45 | B.setPatternMatrix(P.FlowParamScenarios{6}(:,:,P.ScenariosFlowIndex(i,6))') 46 | end 47 | B.solveCompleteHydraulics; 48 | B.saveHydraulicFile([pathname,file0,'.h',num2str(i)]) 49 | end 50 | 51 | pstep=P.PatternTimeStep; 52 | B.setTimeQualityStep(pstep); 53 | zeroNodes=zeros(1,B.NodeCount); 54 | B.setNodeInitialQuality(zeroNodes); 55 | B.setLinkBulkReactionCoeff(zeros(1,B.LinkCount)); 56 | B.setLinkWallReactionCoeff(zeros(1,B.LinkCount)); 57 | 58 | patlen=(P.SimulationTime)*3600/pstep; 59 | if P.newTotalofScenarios ~= P.TotalScenarios 60 | P.ScenariosFlowIndex=cartesianProduct(P.FlowScenarioSets); 61 | P.ScenariosContamIndex=cartesianProduct(P.ContamScenarioSets); 62 | end 63 | sizeflowscenarios=size(P.ScenariosFlowIndex,1); 64 | sizecontscenarios=size(P.ScenariosContamIndex,1); 65 | SensingNodeIndices_NodeBaseDemands=unique([find(P.SensingNodeIndices),find(B.NodeBaseDemands{1})]); 66 | 67 | l=0; 68 | t0=1; 69 | k=1;pp=1; 70 | if isstruct(varargin{1}) 71 | progressbar('Run Multiple Scenarios...') 72 | end 73 | for j=1:(sizeflowscenarios*sizecontscenarios) 74 | t1=tic; 75 | if mod(j,sizecontscenarios)==1 76 | l=l+1; 77 | tmphydfile=[pathname,file0,'.h',num2str(l)]; 78 | B.useHydraulicFile(tmphydfile); 79 | disp(['Hydraulic Scenario ',num2str(l)]) 80 | st2=0; 81 | avtime=inf; 82 | tic; 83 | D{l}=B.getComputedQualityTimeSeries('time','demandSensingNodes',SensingNodeIndices_NodeBaseDemands); 84 | i=1; 85 | end 86 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 87 | if isstruct(varargin{1}) 88 | nload=pp/(sizeflowscenarios*sizecontscenarios); 89 | progressbar(nload) 90 | pp=pp+1; 91 | end 92 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 93 | tmppat=zeros(1,patlen); 94 | tmpstartstep=P.SourceTimes(P.ScenariosContamIndex(i,4)); 95 | tmpendstep=tmpstartstep+round(P.SourceParamScenarios{2}(P.ScenariosContamIndex(i,2))*3600/pstep)-1; 96 | tmppat(tmpstartstep:tmpendstep)=1; 97 | tmp1=B.addPattern('CONTAMINANT',tmppat); 98 | tmpinjloc=P.SourceLocationScenarios{P.ScenariosContamIndex(i,3)}; 99 | tmp2=zeroNodes; 100 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 101 | if tmpinjloc~=0 102 | tmp2(tmpinjloc)=tmp1; 103 | nd_index = find(tmp2); 104 | B.setNodeSourceType(nd_index, 'SETPOINT'); 105 | B.setNodeSourcePatternIndex(tmp2); 106 | tmp2 = zeroNodes; 107 | tmp2(tmpinjloc)=P.SourceParamScenarios{1}(P.ScenariosContamIndex(i,1)); 108 | B.setNodeSourceQuality(tmp2) 109 | end 110 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 111 | C{k}=B.getComputedQualityTimeSeries('qualitySensingNodes',SensingNodeIndices_NodeBaseDemands); 112 | d(k)=l; 113 | t2=toc(t1); 114 | disp(['[Scenario]: ',num2str(i)]) 115 | st2=st2+t2; 116 | avtime=st2/i; 117 | i=i+1; 118 | if mod(j,T)==0; 119 | save([pathname,file0,'.c',num2str(t0)],'C','t0','d','-mat'); 120 | t0=t0+1; 121 | clear C; 122 | clear d; 123 | k=1; 124 | else 125 | k=k+1; 126 | end 127 | end 128 | try 129 | save([pathname,file0,'.c',num2str(t0)],'C','t0','d','-mat'); 130 | clear C; 131 | catch 132 | end 133 | if isstruct(varargin{1}) 134 | progressbar(1); 135 | end 136 | save([pathname,file0,'.c0'],'D','T','l','t0', '-mat'); 137 | SimulateMethod='grid'; 138 | save([pathname,'Simulate.Method'],'SimulateMethod','-mat'); 139 | disp('Run was succesfull.') 140 | end -------------------------------------------------------------------------------- /NETWORKS/Net1_Rossman2000.inp: -------------------------------------------------------------------------------- 1 | [TITLE] 2 | EPANET Example Network 1 3 | A simple example of modeling chlorine decay. Both bulk and 4 | wall reactions are included. 5 | 6 | [JUNCTIONS] 7 | ;ID Elev Demand Pattern 8 | 10 710 0 ; 9 | 11 710 150 ; 10 | 12 700 150 ; 11 | 13 695 100 ; 12 | 21 700 150 ; 13 | 22 695 200 ; 14 | 23 690 150 ; 15 | 31 700 100 ; 16 | 32 710 100 ; 17 | 18 | [RESERVOIRS] 19 | ;ID Head Pattern 20 | 9 800 ; 21 | 22 | [TANKS] 23 | ;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve 24 | 2 850 120 100 150 50.5 0 ; 25 | 26 | [PIPES] 27 | ;ID Node1 Node2 Length Diameter Roughness MinorLoss Status 28 | 10 10 11 10530 18 100 0 Open ; 29 | 11 11 12 5280 14 100 0 Open ; 30 | 12 12 13 5280 10 100 0 Open ; 31 | 21 21 22 5280 10 100 0 Open ; 32 | 22 22 23 5280 12 100 0 Open ; 33 | 31 31 32 5280 6 100 0 Open ; 34 | 110 2 12 200 18 100 0 Open ; 35 | 111 11 21 5280 10 100 0 Open ; 36 | 112 12 22 5280 12 100 0 Open ; 37 | 113 13 23 5280 8 100 0 Open ; 38 | 121 21 31 5280 8 100 0 Open ; 39 | 122 22 32 5280 6 100 0 Open ; 40 | 41 | [PUMPS] 42 | ;ID Node1 Node2 Parameters 43 | 9 9 10 HEAD 1 ; 44 | 45 | [VALVES] 46 | ;ID Node1 Node2 Diameter Type Setting MinorLoss 47 | 48 | [TAGS] 49 | 50 | [DEMANDS] 51 | ;Junction Demand Pattern Category 52 | 53 | [STATUS] 54 | ;ID Status/Setting 55 | 56 | [PATTERNS] 57 | ;ID Multipliers 58 | ;Demand Pattern 59 | 1 1.0 1.2 1.4 1.6 1.4 1.2 60 | 1 1.0 0.8 0.6 0.4 0.6 0.8 61 | 62 | [CURVES] 63 | ;ID X-Value Y-Value 64 | ;PUMP: Pump Curve for Pump 9 65 | 1 1500 250 66 | 67 | [CONTROLS] 68 | LINK 9 OPEN IF NODE 2 BELOW 110 69 | LINK 9 CLOSED IF NODE 2 ABOVE 140 70 | 71 | 72 | [RULES] 73 | 74 | [ENERGY] 75 | Global Efficiency 75 76 | Global Price 0.0 77 | Demand Charge 0.0 78 | 79 | [EMITTERS] 80 | ;Junction Coefficient 81 | 82 | [QUALITY] 83 | ;Node InitQual 84 | 10 0.5 85 | 11 0.5 86 | 12 0.5 87 | 13 0.5 88 | 21 0.5 89 | 22 0.5 90 | 23 0.5 91 | 31 0.5 92 | 32 0.5 93 | 9 1.0 94 | 2 1.0 95 | 96 | [SOURCES] 97 | ;Node Type Quality Pattern 98 | 99 | [REACTIONS] 100 | ;Type Pipe/Tank Coefficient 101 | 102 | 103 | [REACTIONS] 104 | Order Bulk 1 105 | Order Tank 1 106 | Order Wall 1 107 | Global Bulk -.5 108 | Global Wall -1 109 | Limiting Potential 0.0 110 | Roughness Correlation 0.0 111 | 112 | [MIXING] 113 | ;Tank Model 114 | 115 | [TIMES] 116 | Duration 24:00 117 | Hydraulic Timestep 1:00 118 | Quality Timestep 0:05 119 | Pattern Timestep 2:00 120 | Pattern Start 0:00 121 | Report Timestep 1:00 122 | Report Start 0:00 123 | Start ClockTime 12 am 124 | Statistic None 125 | 126 | [REPORT] 127 | Status Yes 128 | Summary No 129 | Page 0 130 | 131 | [OPTIONS] 132 | Units GPM 133 | Headloss H-W 134 | Specific Gravity 1.0 135 | Viscosity 1.0 136 | Trials 40 137 | Accuracy 0.001 138 | Unbalanced Continue 10 139 | Pattern 1 140 | Demand Multiplier 1.0 141 | Emitter Exponent 0.5 142 | Quality Chlorine mg/L 143 | Diffusivity 1.0 144 | Tolerance 0.01 145 | 146 | [COORDINATES] 147 | ;Node X-Coord Y-Coord 148 | 10 20.00 70.00 149 | 11 30.00 70.00 150 | 12 50.00 70.00 151 | 13 70.00 70.00 152 | 21 30.00 40.00 153 | 22 50.00 40.00 154 | 23 70.00 40.00 155 | 31 30.00 10.00 156 | 32 50.00 10.00 157 | 9 10.00 70.00 158 | 2 50.00 90.00 159 | 160 | [VERTICES] 161 | ;Link X-Coord Y-Coord 162 | 163 | [LABELS] 164 | ;X-Coord Y-Coord Label & Anchor Node 165 | 6.99 73.63 "Source" 166 | 13.48 68.13 "Pump" 167 | 43.85 91.21 "Tank" 168 | 169 | [BACKDROP] 170 | DIMENSIONS 7.00 6.00 73.00 94.00 171 | UNITS None 172 | FILE 173 | OFFSET 0.00 0.00 174 | 175 | [END] 176 | -------------------------------------------------------------------------------- /SPLACE/SIMULATE/SimulateRandom/runRandomScenarios.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function [P]=runRandomScenarios(varargin) 16 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 17 | if isstruct(varargin{1}) 18 | file0=varargin{1}.file0; 19 | EditNofSce=varargin{1}.EditNofSce; 20 | T=varargin{1}.T; 21 | else 22 | B=varargin{1}; 23 | P=varargin{2}; 24 | file0=varargin{3}; 25 | EditNofSce=varargin{4}; 26 | T=100; %save every 1000 scenarios 27 | end 28 | 29 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 30 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 31 | 32 | load([pathname,file0,'.0'],'-mat') 33 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 34 | P.ScenariosFlowIndex=P.ScenariosFlowIndex(randi(size(P.ScenariosFlowIndex,1),size(P.ScenariosFlowIndex,1),1),:); 35 | P.ScenariosContamIndex=P.ScenariosContamIndex(randi(size(P.ScenariosContamIndex,1),(EditNofSce)/(size(P.ScenariosFlowIndex,1)),1),:); 36 | a=mod((EditNofSce),(size(P.ScenariosFlowIndex,1))); 37 | if a~=0 38 | P.ScenariosFlowIndex=[P.ScenariosFlowIndex;P.ScenariosFlowIndex(randi(size(P.ScenariosFlowIndex,1),a,1),:)]; 39 | P.ScenariosContamIndex=[P.ScenariosContamIndex;P.ScenariosContamIndex(randi(size(P.ScenariosContamIndex,1),a,1),:)]; 40 | end 41 | B.setQualityType('chem','mg/L') 42 | 43 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 44 | 45 | B.setTimeSimulationDuration(P.SimulationTime*3600); 46 | 47 | for i=1:size(P.ScenariosFlowIndex,1) 48 | B.setLinkDiameter(P.FlowParamScenarios{1}(:, P.ScenariosFlowIndex(i,1))') 49 | B.setLinkLength(P.FlowParamScenarios{2}(:, P.ScenariosFlowIndex(i,2))') 50 | B.setLinkRoughnessCoeff(P.FlowParamScenarios{3}(:, P.ScenariosFlowIndex(i,3))') 51 | B.setNodeElevations(P.FlowParamScenarios{4}(:, P.ScenariosFlowIndex(i,4))') 52 | bs = P.FlowParamScenarios{5}(:, P.ScenariosFlowIndex(i,5))'; 53 | for n = 1:B.getNodeCount 54 | B.setNodeBaseDemands(n, bs(n)) 55 | end 56 | if size(P.Patterns,1)==1 57 | B.setPatternMatrix(P.FlowParamScenarios{6}(:,P.ScenariosFlowIndex(i,6))') 58 | else 59 | B.setPatternMatrix(P.FlowParamScenarios{6}(:,:,P.ScenariosFlowIndex(i,6))') 60 | end 61 | B.solveCompleteHydraulics; 62 | B.saveHydraulicFile([pathname,file0,'.h',num2str(i)]) 63 | end 64 | 65 | pstep=P.PatternTimeStep; 66 | B.setTimeQualityStep(pstep); 67 | zeroNodes=zeros(1,B.NodeCount); 68 | B.setNodeInitialQuality(zeroNodes); 69 | B.setLinkBulkReactionCoeff(zeros(1,B.LinkCount)); 70 | B.setLinkWallReactionCoeff(zeros(1,B.LinkCount)); 71 | patlen=(P.SimulationTime)*3600/pstep; 72 | sizeflowscenarios=size(P.ScenariosFlowIndex,1); 73 | sizecontscenarios=size(P.ScenariosContamIndex,1); 74 | 75 | SensingNodeIndices_NodeBaseDemands=unique([find(P.SensingNodeIndices),find(B.NodeBaseDemands{1})]); 76 | 77 | l=0; 78 | t0=1; 79 | k=1;pp=1; 80 | if isstruct(varargin{1}) 81 | progressbar('Run Random Scenarios...') 82 | end 83 | for j=1:(sizeflowscenarios*sizecontscenarios) 84 | t1=tic; 85 | if mod(j,sizecontscenarios)==1 86 | l=l+1; 87 | tmphydfile=[pathname,file0,'.h',num2str(l)]; 88 | B.useHydraulicFile(tmphydfile); 89 | disp(['Hydraulic Scenario ',num2str(l)]) 90 | st2=0; 91 | avtime=inf; 92 | D{l}=B.getComputedQualityTimeSeries('time','demandSensingNodes',SensingNodeIndices_NodeBaseDemands); 93 | i=1; 94 | end 95 | 96 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 97 | if isstruct(varargin{1}) 98 | nload=pp/(sizeflowscenarios*sizecontscenarios); 99 | progressbar(nload) 100 | pp=pp+1; 101 | end 102 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 103 | 104 | tmppat=zeros(1,patlen); 105 | tmpstartstep=P.SourceTimes(P.ScenariosContamIndex(i,4)); 106 | tmpendstep=tmpstartstep+round(P.SourceParamScenarios{2}(P.ScenariosContamIndex(i,2))*3600/pstep)-1; 107 | tmppat(tmpstartstep:tmpendstep)=1; 108 | tmp1=B.addPattern('CONTAMINANT',tmppat); 109 | tmpinjloc=P.SourceLocationScenarios{P.ScenariosContamIndex(i,3)}; 110 | tmp2=zeroNodes; 111 | 112 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 113 | if tmpinjloc~=0 114 | tmp2(tmpinjloc)=tmp1; 115 | nd_index = find(tmp2); 116 | B.setNodeSourceType(nd_index, 'SETPOINT'); 117 | B.setNodeSourcePatternIndex(tmp2); 118 | tmp2 = zeroNodes; 119 | tmp2(tmpinjloc)=P.SourceParamScenarios{1}(P.ScenariosContamIndex(i,1)); 120 | B.setNodeSourceQuality(tmp2) 121 | end 122 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 123 | C{k}=B.getComputedQualityTimeSeries('qualitySensingNodes',SensingNodeIndices_NodeBaseDemands); 124 | d(k)=l; 125 | t2=toc(t1); 126 | disp(['[Scenario]: ',num2str(i)]) 127 | st2=st2+t2; 128 | avtime=st2/i; 129 | i=i+1; 130 | if mod(j,T)==0; 131 | save([pathname,file0,'.c',num2str(t0)],'C','t0','d','-mat'); 132 | t0=t0+1; 133 | clear C; 134 | clear d; 135 | k=1; 136 | else 137 | k=k+1; 138 | end 139 | end 140 | try 141 | save([pathname,file0,'.c',num2str(t0)],'C','t0','d','-mat'); 142 | clear C; 143 | catch 144 | end 145 | if isstruct(varargin{1}) 146 | progressbar(1); 147 | end 148 | P.newTotalofScenarios=EditNofSce; 149 | save([pathname,file0,'.0'],'P','B','-mat'); 150 | save([pathname,file0,'.c0'],'D','T','l','t0', '-mat'); 151 | SimulateMethod='random'; 152 | save([pathname,'Simulate.Method'],'SimulateMethod','-mat'); 153 | disp('Run was succesfull.') 154 | end -------------------------------------------------------------------------------- /SPLACE/SCENARIOS/GridParameters/ReleaseLocation.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function varargout = ReleaseLocation(varargin) 16 | % RELEASELOCATION MATLAB code for ReleaseLocation.fig 17 | % RELEASELOCATION, by itself, creates a new RELEASELOCATION or raises the existing 18 | % singleton*. 19 | % 20 | % H = RELEASELOCATION returns the handle to a new RELEASELOCATION or the handle to 21 | % the existing singleton*. 22 | % 23 | % RELEASELOCATION('CALLBACK',hObject,eventData,handles,...) calls the local 24 | % function named CALLBACK in RELEASELOCATION.M with the given input arguments. 25 | % 26 | % RELEASELOCATION('Property','Value',...) creates a new RELEASELOCATION or raises the 27 | % existing singleton*. Starting from the left, property value pairs are 28 | % applied to the GUI before ReleaseLocation_OpeningFcn gets called. An 29 | % unrecognized property name or invalid value makes property application 30 | % stop. All inputs are passed to ReleaseLocation_OpeningFcn via varargin. 31 | % 32 | % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 33 | % instance to run (singleton)". 34 | % 35 | % See also: GUIDE, GUIDATA, GUIHANDLES 36 | 37 | % Edit the above text to modify the response to help ReleaseLocation 38 | 39 | % Last Modified by GUIDE v2.5 22-May-2013 02:13:43 40 | 41 | % Begin initialization code - DO NOT EDIT 42 | gui_Singleton = 1; 43 | gui_State = struct('gui_Name', mfilename, ... 44 | 'gui_Singleton', gui_Singleton, ... 45 | 'gui_OpeningFcn', @ReleaseLocation_OpeningFcn, ... 46 | 'gui_OutputFcn', @ReleaseLocation_OutputFcn, ... 47 | 'gui_LayoutFcn', [] , ... 48 | 'gui_Callback', []); 49 | if nargin && ischar(varargin{1}) 50 | gui_State.gui_Callback = str2func(varargin{1}); 51 | end 52 | 53 | if nargout 54 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 55 | else 56 | gui_mainfcn(gui_State, varargin{:}); 57 | end 58 | % End initialization code - DO NOT EDIT 59 | 60 | 61 | % --- Executes just before ReleaseLocation is made visible. 62 | function ReleaseLocation_OpeningFcn(hObject, eventdata, handles, varargin) 63 | % This function has no output args, see OutputFcn. 64 | % hObject handle to figure 65 | % eventdata reserved - to be defined in a future version of MATLAB 66 | % handles structure with handles and user data (see GUIDATA) 67 | % varargin command line arguments to ReleaseLocation (see VARARGIN) 68 | 69 | % Choose default command line output for ReleaseLocation 70 | handles.output = hObject; 71 | % Update handles structure 72 | guidata(hObject, handles); 73 | 74 | % UIWAIT makes ReleaseLocation wait for user response (see UIRESUME) 75 | % uiwait(handles.figure1); 76 | 77 | set(handles.figure1,'name','Release Location'); 78 | % set(handles.figure1,'Position',[75 15 124.6 33.54]); 79 | 80 | SomeDataShared=get(0,'userdata'); 81 | 82 | 83 | for i=1:length(SomeDataShared) 84 | data{i,1} = SomeDataShared{i,1}; 85 | if SomeDataShared{i,2} 86 | data{i,2}= true; 87 | check(i) = data{i,2}; 88 | else 89 | data{i,2}= false; 90 | check(i) = data{i,2}; 91 | end 92 | end 93 | 94 | set(handles.uitable1, 'Data', data); 95 | 96 | if sum(check)==length(check) 97 | set(handles.selectAll,'Value',1); 98 | end 99 | 100 | if ~isempty(varargin) 101 | handles.B = varargin{1}; 102 | end 103 | % Update handles structure 104 | guidata(hObject, handles); 105 | 106 | 107 | % --- Outputs from this function are returned to the command line. 108 | function varargout = ReleaseLocation_OutputFcn(hObject, eventdata, handles) 109 | % varargout cell array for returning output args (see VARARGOUT); 110 | % hObject handle to figure 111 | % eventdata reserved - to be defined in a future version of MATLAB 112 | % handles structure with handles and user data (see GUIDATA) 113 | 114 | % Get default command line output from handles structure 115 | varargout{1} = handles.output; 116 | 117 | 118 | % --- Executes on button press in okbutton. 119 | function okbutton_Callback(hObject, eventdata, handles) 120 | % hObject handle to okbutton (see GCBO) 121 | % eventdata reserved - to be defined in a future version of MATLAB 122 | % handles structure with handles and user data (see GUIDATA) 123 | data=get(handles.uitable1, 'Data'); 124 | a=data(:,2); 125 | for i=1:size(a,1) 126 | b(i)=a{i}; 127 | end 128 | b=sum(b); 129 | if b==0 130 | msgbox(' Select at list one'); 131 | return 132 | end 133 | set(0,'userdata',data); 134 | 135 | 136 | set(handles.figure1,'visible','off'); 137 | close; 138 | 139 | 140 | % --- Executes on button press in pushbutton2. 141 | function pushbutton2_Callback(hObject, eventdata, handles) 142 | % hObject handle to pushbutton2 (see GCBO) 143 | % eventdata reserved - to be defined in a future version of MATLAB 144 | % handles structure with handles and user data (see GUIDATA) 145 | 146 | set(handles.figure1,'visible','off'); 147 | close; 148 | 149 | % --- Executes on button press in selectAll. 150 | function selectAll_Callback(hObject, eventdata, handles) 151 | % hObject handle to selectAll (see GCBO) 152 | % eventdata reserved - to be defined in a future version of MATLAB 153 | % handles structure with handles and user data (see GUIDATA) 154 | 155 | % Hint: get(hObject,'Value') returns toggle state of selectAll 156 | 157 | check=get(handles.selectAll,'Value'); 158 | 159 | if check 160 | handles.release(1:handles.B.NodeCount)={true}; 161 | else 162 | handles.release(1:handles.B.NodeCount)={false}; 163 | end 164 | 165 | for i=1:handles.B.NodeCount 166 | data{i,1} = handles.B.NodeNameID{i}; 167 | data{i,2}= handles.release{i}; 168 | end 169 | set(handles.uitable1, 'data', data); 170 | handles.data=data; 171 | % Update handles structure 172 | guidata(hObject, handles); 173 | 174 | % --- Executes on button press in SelectNone. 175 | function SelectNone_Callback(hObject, eventdata, handles) 176 | % hObject handle to SelectNone (see GCBO) 177 | % eventdata reserved - to be defined in a future version of MATLAB 178 | % handles structure with handles and user data (see GUIDATA) 179 | 180 | % Hint: get(hObject,'Value') returns toggle state of SelectNone 181 | 182 | 183 | % --- Executes when selected cell(s) is changed in uitable1. 184 | function uitable1_CellSelectionCallback(hObject, eventdata, handles) 185 | % hObject handle to uitable1 (see GCBO) 186 | % eventdata structure with the following fields (see UITABLE) 187 | % Indices: row and column indices of the cell(s) currently selecteds 188 | % handles structure with handles and user data (see GUIDATA) 189 | 190 | 191 | % --- Executes when user attempts to close figure1. 192 | function figure1_CloseRequestFcn(hObject, eventdata, handles) 193 | % hObject handle to figure1 (see GCBO) 194 | % eventdata reserved - to be defined in a future version of MATLAB 195 | % handles structure with handles and user data (see GUIDATA) 196 | 197 | % Hint: delete(hObject) closes the figure 198 | delete(hObject); 199 | -------------------------------------------------------------------------------- /SPLACE/IMPACT/CWCV/CWCV.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function varargout = CWCV(varargin) 16 | % CWCV M-file for CWCV.fig 17 | % In This M file you can see how the axes along with a patch can be used to 18 | % render a progress bar for your existing Gui. Box Property of the Axes 19 | % must be enabled in order to make the axes look like a progress bar and 20 | % also the xTick & yTick values must be set to empty. In order to change 21 | % the Color of the Patch do pass the color value to changecolor function. 22 | % Run this m file and click on the start button to see how this progress bar works. 23 | gui_Singleton = 1; 24 | gui_State = struct('gui_Name', mfilename, ... 25 | 'gui_Singleton', gui_Singleton, ... 26 | 'gui_OpeningFcn', @CWCV_OpeningFcn, ... 27 | 'gui_OutputFcn', @CWCV_OutputFcn, ... 28 | 'gui_LayoutFcn', [] , ... 29 | 'gui_Callback', []); 30 | if nargin && ischar(varargin{1}) 31 | gui_State.gui_Callback = str2func(varargin{1}); 32 | end 33 | 34 | if nargout 35 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 36 | else 37 | gui_mainfcn(gui_State, varargin{:}); 38 | end 39 | % End initialization code - DO NOT EDIT 40 | 41 | 42 | % --- Executes just before CWCV is made visible. 43 | function CWCV_OpeningFcn(hObject, eventdata, handles, varargin) 44 | % This function has no output args, see OutputFcn. 45 | % hObject handle to figure 46 | % eventdata reserved - to be defined in a future version of MATLAB 47 | % handles structure with handles and user data (see GUIDATA) 48 | % varargin command line arguments to CWCV (see VARARGIN) 49 | % Choose default command line output for CWCV 50 | handles.output = hObject; 51 | 52 | handles.file0 = varargin{1}.file0; 53 | handles.B = varargin{1}.B; 54 | handles.LoadText = varargin{1}.LoadText; 55 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 56 | 57 | if exist([pathname,handles.file0,'.0'],'file') 58 | if ~isempty([handles.file0,'.0']) 59 | load([pathname,handles.file0,'.0'],'-mat'); 60 | else 61 | B.InputFile=handles.B.InputFile; 62 | end 63 | else 64 | B.InputFile=[]; 65 | end 66 | 67 | if ~strcmp(handles.B.InputFile,B.InputFile) 68 | set(handles.start,'enable','off'); 69 | set(handles.SensorThreshold,'enable','off'); 70 | set(handles.FileText,'String','') 71 | else 72 | set(handles.start,'enable','on'); 73 | set(handles.SensorThreshold,'enable','on'); 74 | set(handles.FileText,'String',[handles.file0,'.0']) 75 | SensorThreshold=0.3; 76 | set(handles.SensorThreshold,'String',SensorThreshold); 77 | end 78 | 79 | set(handles.load,'enable','on'); 80 | handles.str='Compute Impact Matrix (CWCV)'; 81 | set(handles.figure1,'name',handles.str); 82 | % Update handles structure 83 | guidata(hObject, handles); 84 | 85 | % --- Outputs from this function are returned to the command line. 86 | function varargout = CWCV_OutputFcn(hObject, eventdata, handles) 87 | % varargout cell array for returning output args (see VARARGOUT); 88 | % hObject handle to figure 89 | % eventdata reserved - to be defined in a future version of MATLAB 90 | % handles structure with handles and user data (see GUIDATA) 91 | 92 | % Get default command line output from handles structure 93 | varargout{1} = handles.output; 94 | 95 | % --- Executes on button press in start. 96 | function start_Callback(hObject, eventdata, handles) 97 | % hObject handle to start (see GCBO) 98 | % eventdata reserved - to be defined in a future version of MATLAB 99 | % handles structure with handles and user data (see GUIDATA) 100 | 101 | handles.SensorThreshold1=str2num(get(handles.SensorThreshold, 'String')); 102 | if ~length(handles.SensorThreshold1) || handles.SensorThreshold1<0 103 | msgbox('Give number of Sensor Threshold', 'Error', 'modal') 104 | return 105 | end 106 | 107 | set(handles.start,'enable','off'); 108 | set(handles.load,'enable','off'); 109 | 110 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 111 | % Method 112 | ComputeImpactMatrices(handles) 113 | try 114 | close(findobj('type','figure','name','Compute Impact Matrix (CWCV)')) 115 | catch 116 | end 117 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 118 | try 119 | load([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 120 | set(handles.LoadText,'Value',1); 121 | msg=[msg;{['>>Computed Impact Matrix in file "',handles.file0,'.w','"']}]; 122 | set(handles.LoadText,'String',msg); 123 | set(handles.LoadText,'Value',length(msg)); 124 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 125 | catch 126 | end 127 | 128 | % --- Executes on button press in load. 129 | function load_Callback(hObject, eventdata, handles) 130 | % hObject handle to load (see GCBO) 131 | % eventdata reserved - to be defined in a future version of MATLAB 132 | % handles structure with handles and user data (see GUIDATA) 133 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 134 | 135 | [file0,pathNM] = uigetfile([pathname,'*.0'],'Select the MATLAB *.0 file'); 136 | if length(pathNM)~=1 137 | pathname=pathNM; 138 | end 139 | 140 | file0=file0(1:end-2); 141 | if isnumeric(file0) 142 | file0=[]; 143 | end 144 | if ~isempty((file0)) 145 | save([pwd,'\RESULTS\','File0.File'],'file0','-mat'); 146 | load([pathname,file0,'.0'],'-mat'); 147 | handles.file0=file0; 148 | if ~strcmp(handles.B.InputFile,B.InputFile) %|| ~exist([handles.file0,'.w'],'file') 149 | set(handles.start,'enable','off'); 150 | set(handles.SensorThreshold,'enable','off'); 151 | load([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 152 | msg=[msg;{['>>Wrong File0 "',file0,'"']}]; 153 | set(handles.LoadText,'String',msg); 154 | set(handles.LoadText,'Value',length(msg)); 155 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 156 | set(handles.FileText,'String','') 157 | else 158 | set(handles.start,'enable','on'); 159 | set(handles.SensorThreshold,'enable','on'); 160 | SensorThreshold=0.3; 161 | set(handles.SensorThreshold,'String',SensorThreshold); 162 | set(handles.FileText,'String',[handles.file0,'.0']) 163 | end 164 | handles.P=P; 165 | hanldes.B=B; 166 | % Update handles structure 167 | guidata(hObject, handles); 168 | end 169 | save([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 170 | 171 | % --- Executes on mouse press over axes background. 172 | function axes2_ButtonDownFcn(hObject, eventdata, handles) 173 | % hObject handle to axes2 (see GCBO) 174 | % eventdata reserved - to be defined in a future version of MATLAB 175 | % handles structure with handles and user data (see GUIDATA) 176 | 177 | 178 | 179 | function SensorThreshold_Callback(hObject, eventdata, handles) 180 | % hObject handle to SensorThreshold (see GCBO) 181 | % eventdata reserved - to be defined in a future version of MATLAB 182 | % handles structure with handles and user data (see GUIDATA) 183 | 184 | % Hints: get(hObject,'String') returns contents of SensorThreshold as text 185 | % str2double(get(hObject,'String')) returns contents of SensorThreshold as a double 186 | 187 | 188 | % --- Executes during object creation, after setting all properties. 189 | function SensorThreshold_CreateFcn(hObject, eventdata, handles) 190 | % hObject handle to SensorThreshold (see GCBO) 191 | % eventdata reserved - to be defined in a future version of MATLAB 192 | % handles empty - handles not created until after all CreateFcns called 193 | 194 | % Hint: edit controls usually have a white background on Windows. 195 | % See ISPC and COMPUTER. 196 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 197 | set(hObject,'BackgroundColor','white'); 198 | end 199 | -------------------------------------------------------------------------------- /SPLACE/SCENARIOS/GridParameters/SensingLocation.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function varargout = SensingLocation(varargin) 16 | % SENSINGLOCATION MATLAB code for SensingLocation.fig 17 | % SENSINGLOCATION, by itself, creates a new SENSINGLOCATION or raises the existing 18 | % singleton*. 19 | % 20 | % H = SENSINGLOCATION returns the handle to a new SENSINGLOCATION or the handle to 21 | % the existing singleton*. 22 | % 23 | % SENSINGLOCATION('CALLBACK',hObject,eventData,handles,...) calls the local 24 | % function named CALLBACK in SENSINGLOCATION.M with the given input arguments. 25 | % 26 | % SENSINGLOCATION('Property','Value',...) creates a new SENSINGLOCATION or raises the 27 | % existing singleton*. Starting from the left, property value pairs are 28 | % applied to the GUI before SensingLocation_OpeningFcn gets called. An 29 | % unrecognized property name or invalid value makes property application 30 | % stop. All inputs are passed to SensingLocation_OpeningFcn via varargin. 31 | % 32 | % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 33 | % instance to run (singleton)". 34 | % 35 | % See also: GUIDE, GUIDATA, GUIHANDLES 36 | 37 | % Edit the above text to modify the response to help SensingLocation 38 | 39 | % Last Modified by GUIDE v2.5 30-May-2013 16:56:34 40 | 41 | % Begin initialization code - DO NOT EDIT 42 | gui_Singleton = 1; 43 | gui_State = struct('gui_Name', mfilename, ... 44 | 'gui_Singleton', gui_Singleton, ... 45 | 'gui_OpeningFcn', @SensingLocation_OpeningFcn, ... 46 | 'gui_OutputFcn', @SensingLocation_OutputFcn, ... 47 | 'gui_LayoutFcn', [] , ... 48 | 'gui_Callback', []); 49 | if nargin && ischar(varargin{1}) 50 | gui_State.gui_Callback = str2func(varargin{1}); 51 | end 52 | 53 | if nargout 54 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 55 | else 56 | gui_mainfcn(gui_State, varargin{:}); 57 | end 58 | % End initialization code - DO NOT EDIT 59 | 60 | 61 | % --- Executes just before SensingLocation is made visible. 62 | function SensingLocation_OpeningFcn(hObject, eventdata, handles, varargin) 63 | % This function has no output args, see OutputFcn. 64 | % hObject handle to figure 65 | % eventdata reserved - to be defined in a future version of MATLAB 66 | % handles structure with handles and user data (see GUIDATA) 67 | % varargin command line arguments to SensingLocation (see VARARGIN) 68 | 69 | % Choose default command line output for SensingLocation 70 | handles.output = hObject; 71 | if ~isempty(varargin) 72 | handles.sensing = varargin{2}; 73 | end 74 | % Update handles structure 75 | guidata(hObject, handles); 76 | 77 | % UIWAIT makes SensingLocation wait for user response (see UIRESUME) 78 | % uiwait(handles.figure1); 79 | 80 | set(handles.figure1,'name','Sensing Location'); 81 | % set(handles.figure1,'Position',[75 15 124.6 33.54]); 82 | 83 | SomeDataShared=get(0,'userdata'); 84 | 85 | 86 | for i=1:length(SomeDataShared) 87 | data{i,1} = SomeDataShared{i,1}; 88 | if SomeDataShared{i,2} 89 | data{i,2}= true; 90 | check(i) = data{i,2}; 91 | else 92 | data{i,2}= false; 93 | check(i) = data{i,2}; 94 | end 95 | end 96 | 97 | set(handles.uitable1, 'Data', data); 98 | 99 | if sum(check)==length(check) 100 | set(handles.selectAll,'Value',1); 101 | end 102 | 103 | if ~isempty(varargin) 104 | handles.B = varargin{1}; 105 | end 106 | % Update handles structure 107 | guidata(hObject, handles); 108 | 109 | 110 | % --- Outputs from this function are returned to the command line. 111 | function varargout = SensingLocation_OutputFcn(hObject, eventdata, handles) 112 | % varargout cell array for returning output args (see VARARGOUT); 113 | % hObject handle to figure 114 | % eventdata reserved - to be defined in a future version of MATLAB 115 | % handles structure with handles and user data (see GUIDATA) 116 | 117 | % Get default command line output from handles structure 118 | varargout{1} = handles.output; 119 | 120 | 121 | % --- Executes on button press in okbutton. 122 | function okbutton_Callback(hObject, eventdata, handles) 123 | % hObject handle to okbutton (see GCBO) 124 | % eventdata reserved - to be defined in a future version of MATLAB 125 | % handles structure with handles and user data (see GUIDATA) 126 | data=get(handles.uitable1, 'Data'); 127 | 128 | a=data(:,2); 129 | for i=1:size(a,1) 130 | b(i)=a{i}; 131 | end 132 | b=sum(b); 133 | if b==0 134 | msgbox(' Select at list one'); 135 | return 136 | end 137 | set(0,'userdata',data); 138 | 139 | 140 | set(handles.figure1,'visible','off'); 141 | close; 142 | 143 | 144 | % --- Executes on button press in pushbutton2. 145 | function pushbutton2_Callback(hObject, eventdata, handles) 146 | % hObject handle to pushbutton2 (see GCBO) 147 | % eventdata reserved - to be defined in a future version of MATLAB 148 | % handles structure with handles and user data (see GUIDATA) 149 | 150 | set(handles.figure1,'visible','off'); 151 | close; 152 | 153 | % --- Executes on button press in selectAll. 154 | function selectAll_Callback(hObject, eventdata, handles) 155 | % hObject handle to selectAll (see GCBO) 156 | % eventdata reserved - to be defined in a future version of MATLAB 157 | % handles structure with handles and user data (see GUIDATA) 158 | 159 | % Hint: get(hObject,'Value') returns toggle state of selectAll 160 | set(handles.NonZero,'Value',0); 161 | 162 | check=get(handles.selectAll,'Value'); 163 | 164 | if check 165 | handles.release(1:handles.B.NodeCount)={true}; 166 | else 167 | handles.release(1:handles.B.NodeCount)={false}; 168 | end 169 | 170 | for i=1:handles.B.NodeCount 171 | data{i,1} = handles.B.NodeNameID{i}; 172 | data{i,2}= handles.release{i}; 173 | end 174 | set(handles.uitable1, 'data', data); 175 | handles.data=data; 176 | % Update handles structure 177 | guidata(hObject, handles); 178 | 179 | % --- Executes on button press in SelectNone. 180 | function SelectNone_Callback(hObject, eventdata, handles) 181 | % hObject handle to SelectNone (see GCBO) 182 | % eventdata reserved - to be defined in a future version of MATLAB 183 | % handles structure with handles and user data (see GUIDATA) 184 | 185 | % Hint: get(hObject,'Value') returns toggle state of SelectNone 186 | 187 | 188 | % --- Executes when selected cell(s) is changed in uitable1. 189 | function uitable1_CellSelectionCallback(hObject, eventdata, handles) 190 | % hObject handle to uitable1 (see GCBO) 191 | % eventdata structure with the following fields (see UITABLE) 192 | % Indices: row and column indices of the cell(s) currently selecteds 193 | % handles structure with handles and user data (see GUIDATA) 194 | 195 | 196 | % --- Executes when user attempts to close figure1. 197 | function figure1_CloseRequestFcn(hObject, eventdata, handles) 198 | % hObject handle to figure1 (see GCBO) 199 | % eventdata reserved - to be defined in a future version of MATLAB 200 | % handles structure with handles and user data (see GUIDATA) 201 | 202 | % Hint: delete(hObject) closes the figure 203 | delete(hObject); 204 | 205 | 206 | % --- Executes on button press in NonZero. 207 | function NonZero_Callback(hObject, eventdata, handles) 208 | % hObject handle to NonZero (see GCBO) 209 | % eventdata reserved - to be defined in a future version of MATLAB 210 | % handles structure with handles and user data (see GUIDATA) 211 | 212 | % Hint: get(hObject,'Value') returns toggle state of NonZero 213 | set(handles.selectAll,'Value',0); 214 | 215 | bd=find(handles.B.NodeBaseDemands{1}); 216 | 217 | check=get(handles.NonZero,'Value'); 218 | if check 219 | for i=1:handles.B.NodeCount 220 | data{i,1} = handles.B.NodeNameID{i}; 221 | if sum(find(bd==i)) 222 | data{i,2}= true; 223 | else 224 | data{i,2}= false; 225 | end 226 | end 227 | set(handles.uitable1, 'data', data); 228 | else 229 | for i=1:handles.B.NodeCount 230 | data{i,1} = handles.B.NodeNameID{i}; 231 | data{i,2}= false; 232 | end 233 | set(handles.uitable1, 'data', data); 234 | end 235 | -------------------------------------------------------------------------------- /SPLACE/SIMULATE/SimulateRandom/SimulateRandom.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function varargout = SimulateRandom(varargin) 16 | % SIMULATERANDOM M-file for SimulateRandom.fig 17 | % In This M file you can see how the axes along with a patch can be used to 18 | % render a progress bar for your existing Gui. Box Property of the Axes 19 | % must be enabled in order to make the axes look like a progress bar and 20 | % also the xTick & yTick values must be set to empty. In order to change 21 | % the Color of the Patch do pass the color value to changecolor function. 22 | % Run this m file and click on the start button to see how this progress bar works. 23 | gui_Singleton = 1; 24 | gui_State = struct('gui_Name', mfilename, ... 25 | 'gui_Singleton', gui_Singleton, ... 26 | 'gui_OpeningFcn', @SimulateRandom_OpeningFcn, ... 27 | 'gui_OutputFcn', @SimulateRandom_OutputFcn, ... 28 | 'gui_LayoutFcn', [] , ... 29 | 'gui_Callback', []); 30 | if nargin && ischar(varargin{1}) 31 | gui_State.gui_Callback = str2func(varargin{1}); 32 | end 33 | 34 | if nargout 35 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 36 | else 37 | gui_mainfcn(gui_State, varargin{:}); 38 | end 39 | % End initialization code - DO NOT EDIT 40 | 41 | 42 | % --- Executes just before SimulateRandom is made visible. 43 | function SimulateRandom_OpeningFcn(hObject, eventdata, handles, varargin) 44 | % This function has no output args, see OutputFcn. 45 | % hObject handle to figure 46 | % eventdata reserved - to be defined in a future version of MATLAB 47 | % handles structure with handles and user data (see GUIDATA) 48 | % varargin command line arguments to SimulateRandom (see VARARGIN) 49 | % Choose default command line output for SimulateRandom 50 | handles.output = hObject; 51 | 52 | handles.file0 = varargin{1}.file0; 53 | handles.B = varargin{1}.B; 54 | handles.LoadText = varargin{1}.LoadText; 55 | handles.runMultipleScenarios = varargin{1}.runMultipleScenarios; 56 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 57 | 58 | if exist([pathname,handles.file0,'.0'],'file')==2 59 | if ~isempty([handles.file0,'.0']) 60 | load([pathname,handles.file0,'.0'],'-mat'); 61 | else 62 | B.InputFile=handles.B.InputFile; 63 | end 64 | else 65 | B.InputFile=[]; 66 | end 67 | 68 | if ~strcmp(handles.B.InputFile,B.InputFile) 69 | set(handles.start,'enable','off'); 70 | set(handles.SaveEveryScenarios,'enable','off'); 71 | set(handles.EditNumberOfScenarios,'enable','off'); 72 | set(handles.FileText,'String','') 73 | else 74 | set(handles.start,'enable','on'); 75 | set(handles.SaveEveryScenarios,'enable','on'); 76 | set(handles.EditNumberOfScenarios,'enable','on'); 77 | set(handles.FileText,'String',[handles.file0,'.0']) 78 | T=100;%SaveEvreyScenarios 79 | handles.TotalNofSce=P.TotalScenarios; 80 | if T>handles.TotalNofSce 81 | T=handles.TotalNofSce; 82 | end 83 | set(handles.SaveEveryScenarios,'String',T); 84 | set(handles.TotalScenarios,'String',handles.TotalNofSce); 85 | set(handles.EditNumberOfScenarios,'String',round(handles.TotalNofSce/10)); 86 | end 87 | 88 | set(handles.load,'enable','on'); 89 | handles.str='Simulate Random Scenarios'; 90 | set(handles.figure1,'name',handles.str); 91 | % Update handles structure 92 | guidata(hObject, handles); 93 | 94 | 95 | % --- Outputs from this function are returned to the command line. 96 | function varargout = SimulateRandom_OutputFcn(hObject, eventdata, handles) 97 | % varargout cell array for returning output args (see VARARGOUT); 98 | % hObject handle to figure 99 | % eventdata reserved - to be defined in a future version of MATLAB 100 | % handles structure with handles and user data (see GUIDATA) 101 | 102 | % Get default command line output from handles structure 103 | varargout{1} = handles.output; 104 | 105 | % --- Executes on button press in start. 106 | function start_Callback(hObject, eventdata, handles) 107 | % hObject handle to start (see GCBO) 108 | % eventdata reserved - to be defined in a future version of MATLAB 109 | % handles structure with handles and user data (see GUIDATA) 110 | 111 | handles.T=str2num(get(handles.SaveEveryScenarios, 'String')); 112 | if ~length(handles.T) || handles.T<0 || handles.T>handles.TotalNofSce 113 | msgbox(' Give number of save every scenarios', 'Error', 'modal') 114 | return 115 | end 116 | 117 | handles.EditNofSce=str2num(get(handles.EditNumberOfScenarios, 'String')); 118 | if ~length(handles.EditNofSce) || handles.EditNofSce<0 || handles.EditNofSce>handles.TotalNofSce 119 | msgbox(' Give number of scenarios', 'Error', 'modal') 120 | return 121 | end 122 | 123 | set(handles.start,'enable','off'); 124 | set(handles.load,'enable','off'); 125 | 126 | runRandomScenarios(handles); 127 | handles.B.loadEPANETFile(handles.B.BinTempfile);clc; 128 | try 129 | close(findobj('type','figure','name','Simulate Random Scenarios')) 130 | catch 131 | end 132 | 133 | try 134 | load([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 135 | msg=[msg;{'>>Create Hydraulic and Quality files.'}]; 136 | set(handles.LoadText,'String',msg); 137 | set(handles.LoadText,'Value',length(msg)); 138 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 139 | catch 140 | end 141 | 142 | % --- Executes on button press in load. 143 | function load_Callback(hObject, eventdata, handles) 144 | % hObject handle to load (see GCBO) 145 | % eventdata reserved - to be defined in a future version of MATLAB 146 | % handles structure with handles and user data (see GUIDATA) 147 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 148 | 149 | [file0,pathNM] = uigetfile([pathname,'*.0'],'Select the MATLAB *.0 file'); 150 | if length(pathNM)~=1 151 | pathname=pathNM; 152 | end 153 | file0=file0(1:end-2); 154 | if isnumeric(file0) 155 | file0=[]; 156 | end 157 | if ~isempty((file0)) 158 | save([pwd,'\RESULTS\','File0.File'],'file0','-mat'); 159 | load([pathname,file0,'.0'],'-mat'); 160 | handles.file0=file0; 161 | if ~strcmp(handles.B.InputFile,B.InputFile) 162 | set(handles.start,'enable','off'); 163 | set(handles.EditNumberOfScenarios,'enable','off'); 164 | set(handles.SaveEveryScenarios,'enable','off'); 165 | load([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 166 | msg=[msg;{['>>Wrong File0 "',file0,'"']}]; 167 | set(handles.LoadText,'String',msg); 168 | set(handles.LoadText,'Value',length(msg)); 169 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 170 | set(handles.FileText,'String','') 171 | else 172 | set(handles.start,'enable','on'); 173 | set(handles.EditNumberOfScenarios,'enable','on'); 174 | set(handles.SaveEveryScenarios,'enable','on'); 175 | T=100;%SaveEvreyScenarios 176 | handles.TotalNofSce=P.TotalScenarios; 177 | if T>handles.TotalNofSce 178 | T=handles.TotalNofSce; 179 | end 180 | set(handles.SaveEveryScenarios,'String',T); 181 | set(handles.FileText,'String',[handles.file0,'.0']) 182 | set(handles.TotalScenarios,'String',handles.TotalNofSce); 183 | set(handles.EditNumberOfScenarios,'String',round(handles.TotalNofSce/10)); 184 | end 185 | handles.P=P; 186 | hanldes.B=B; 187 | % Update handles structure 188 | guidata(hObject, handles); 189 | end 190 | save([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 191 | 192 | % --- Executes on mouse press over axes background. 193 | function axes2_ButtonDownFcn(hObject, eventdata, handles) 194 | % hObject handle to axes2 (see GCBO) 195 | % eventdata reserved - to be defined in a future version of MATLAB 196 | % handles structure with handles and user data (see GUIDATA) 197 | 198 | 199 | 200 | function SaveEveryScenarios_Callback(hObject, eventdata, handles) 201 | % hObject handle to SaveEveryScenarios (see GCBO) 202 | % eventdata reserved - to be defined in a future version of MATLAB 203 | % handles structure with handles and user data (see GUIDATA) 204 | 205 | % Hints: get(hObject,'String') returns contents of SaveEveryScenarios as text 206 | % str2double(get(hObject,'String')) returns contents of SaveEveryScenarios as a double 207 | 208 | 209 | % --- Executes during object creation, after setting all properties. 210 | function SaveEveryScenarios_CreateFcn(hObject, eventdata, handles) 211 | % hObject handle to SaveEveryScenarios (see GCBO) 212 | % eventdata reserved - to be defined in a future version of MATLAB 213 | % handles empty - handles not created until after all CreateFcns called 214 | 215 | % Hint: edit controls usually have a white background on Windows. 216 | % See ISPC and COMPUTER. 217 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 218 | set(hObject,'BackgroundColor','white'); 219 | end 220 | 221 | 222 | 223 | function EditNumberOfScenarios_Callback(hObject, eventdata, handles) 224 | % hObject handle to EditNumberOfScenarios (see GCBO) 225 | % eventdata reserved - to be defined in a future version of MATLAB 226 | % handles structure with handles and user data (see GUIDATA) 227 | 228 | % Hints: get(hObject,'String') returns contents of EditNumberOfScenarios as text 229 | % str2double(get(hObject,'String')) returns contents of EditNumberOfScenarios as a double 230 | 231 | 232 | % --- Executes during object creation, after setting all properties. 233 | function EditNumberOfScenarios_CreateFcn(hObject, eventdata, handles) 234 | % hObject handle to EditNumberOfScenarios (see GCBO) 235 | % eventdata reserved - to be defined in a future version of MATLAB 236 | % handles empty - handles not created until after all CreateFcns called 237 | 238 | % Hint: edit controls usually have a white background on Windows. 239 | % See ISPC and COMPUTER. 240 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 241 | set(hObject,'BackgroundColor','white'); 242 | end 243 | 244 | 245 | % --- Executes during object creation, after setting all properties. 246 | function TotalScenarios_CreateFcn(hObject, eventdata, handles) 247 | % hObject handle to TotalScenarios (see GCBO) 248 | % eventdata reserved - to be defined in a future version of MATLAB 249 | % handles empty - handles not created until after all CreateFcns called 250 | 251 | 252 | 253 | -------------------------------------------------------------------------------- /SPLACE/SIMULATE/SimulateAll/SimulateAll.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function varargout = SimulateAll(varargin) 16 | % SimulateAll M-file for SimulateAll.fig 17 | % In This M file you can see how the axes along with a patch can be used to 18 | % render a progress bar for your existing Gui. Box Property of the Axes 19 | % must be enabled in order to make the axes look like a progress bar and 20 | % also the xTick & yTick values must be set to empty. In order to change 21 | % the Color of the Patch do pass the color value to changecolor function. 22 | % Run this m file and click on the start button to see how this progress bar works. 23 | gui_Singleton = 1; 24 | gui_State = struct('gui_Name', mfilename, ... 25 | 'gui_Singleton', gui_Singleton, ... 26 | 'gui_OpeningFcn', @SimulateAll_OpeningFcn, ... 27 | 'gui_OutputFcn', @SimulateAll_OutputFcn, ... 28 | 'gui_LayoutFcn', [] , ... 29 | 'gui_Callback', []); 30 | if nargin && ischar(varargin{1}) 31 | gui_State.gui_Callback = str2func(varargin{1}); 32 | end 33 | 34 | if nargout 35 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 36 | else 37 | gui_mainfcn(gui_State, varargin{:}); 38 | end 39 | % End initialization code - DO NOT EDIT 40 | 41 | 42 | % --- Executes just before SimulateAll is made visible. 43 | function SimulateAll_OpeningFcn(hObject, eventdata, handles, varargin) 44 | % This function has no output args, see OutputFcn. 45 | % hObject handle to figure 46 | % eventdata reserved - to be defined in a future version of MATLAB 47 | % handles structure with handles and user data (see GUIDATA) 48 | % varargin command line arguments to SimulateAll (see VARARGIN) 49 | % Choose default command line output for SimulateAll 50 | handles.output = hObject; 51 | 52 | handles.file0 = varargin{1}.file0; 53 | handles.B = varargin{1}.B; 54 | handles.LoadText = varargin{1}.LoadText; 55 | handles.runMultipleScenarios = varargin{1}.runMultipleScenarios; 56 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 57 | 58 | if exist([pathname,handles.file0,'.0'],'file')==2 59 | if ~isempty([handles.file0,'.0']) 60 | load([pathname,handles.file0,'.0'],'-mat'); 61 | else 62 | B.InputFile=handles.B.InputFile; 63 | end 64 | else 65 | B.InputFile=[]; 66 | end 67 | 68 | if ~strcmp(handles.B.InputFile,B.InputFile) 69 | set(handles.start,'enable','off'); 70 | set(handles.SaveEveryScenarios,'enable','off'); 71 | %set(handles.EditNumberOfScenarios,'enable','off'); 72 | set(handles.FileText,'String','') 73 | else 74 | set(handles.start,'enable','on'); 75 | set(handles.SaveEveryScenarios,'enable','on'); 76 | %set(handles.EditNumberOfScenarios,'enable','on'); 77 | set(handles.FileText,'String',[handles.file0,'.0']) 78 | T=100;%SaveEvreyScenarios 79 | handles.TotalNofSce=P.TotalScenarios; 80 | if T>handles.TotalNofSce 81 | T=handles.TotalNofSce; 82 | end 83 | set(handles.SaveEveryScenarios,'String',T); 84 | set(handles.TotalScenarios,'String',handles.TotalNofSce); 85 | %set(handles.EditNumberOfScenarios,'String',handles.TotalNofSce); 86 | end 87 | 88 | set(handles.load,'enable','on'); 89 | handles.str='Simulate All Scenarios'; 90 | set(handles.figure1,'name',handles.str); 91 | % Update handles structure 92 | guidata(hObject, handles); 93 | 94 | 95 | % --- Outputs from this function are returned to the command line. 96 | function varargout = SimulateAll_OutputFcn(hObject, eventdata, handles) 97 | % varargout cell array for returning output args (see VARARGOUT); 98 | % hObject handle to figure 99 | % eventdata reserved - to be defined in a future version of MATLAB 100 | % handles structure with handles and user data (see GUIDATA) 101 | 102 | % Get default command line output from handles structure 103 | varargout{1} = handles.output; 104 | 105 | % --- Executes on button press in start. 106 | function start_Callback(hObject, eventdata, handles) 107 | % hObject handle to start (see GCBO) 108 | % eventdata reserved - to be defined in a future version of MATLAB 109 | % handles structure with handles and user data (see GUIDATA) 110 | 111 | handles.T=str2num(get(handles.SaveEveryScenarios, 'String')); 112 | if ~length(handles.T) || handles.T<0 || handles.T>handles.TotalNofSce 113 | msgbox(' Give number of save every scenarios', 'Error', 'modal') 114 | return 115 | end 116 | 117 | set(handles.start,'enable','off'); 118 | set(handles.load,'enable','off'); 119 | runMultipleScenarios(handles) 120 | handles.B.loadEPANETFile(handles.B.BinTempfile);clc; 121 | try 122 | close(findobj('type','figure','name','Simulate All Scenarios')) 123 | catch 124 | end 125 | 126 | try 127 | load([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 128 | msg=[msg;{'>>Create Hydraulic and Quality files.'}]; 129 | set(handles.LoadText,'String',msg); 130 | set(handles.LoadText,'Value',length(msg)); 131 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 132 | catch 133 | end 134 | % set(handles.runMultipleScenarios,'enable','off'); 135 | 136 | % --- Executes on button press in load. 137 | function load_Callback(hObject, eventdata, handles) 138 | % hObject handle to load (see GCBO) 139 | % eventdata reserved - to be defined in a future version of MATLAB 140 | % handles structure with handles and user data (see GUIDATA) 141 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 142 | 143 | [file0,pathNM] = uigetfile([pathname,'*.0'],'Select the MATLAB *.0 file'); 144 | if length(pathNM)~=1 145 | pathname=pathNM; 146 | end 147 | 148 | file0=file0(1:end-2); 149 | if isnumeric(file0) 150 | file0=[]; 151 | end 152 | if ~isempty((file0)) 153 | save([pwd,'\RESULTS\','File0.File'],'file0','-mat'); 154 | load([pathname,file0,'.0'],'-mat'); 155 | handles.file0=file0; 156 | if ~strcmp(handles.B.InputFile,B.InputFile) 157 | set(handles.start,'enable','off'); 158 | %set(handles.EditNumberOfScenarios,'enable','off'); 159 | set(handles.SaveEveryScenarios,'enable','off'); 160 | load([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 161 | msg=[msg;{['>>Wrong File0 "',file0,'"']}]; 162 | set(handles.LoadText,'String',msg); 163 | set(handles.LoadText,'Value',length(msg)); 164 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 165 | set(handles.FileText,'String','') 166 | else 167 | set(handles.start,'enable','on'); 168 | %set(handles.EditNumberOfScenarios,'enable','on'); 169 | set(handles.SaveEveryScenarios,'enable','on'); 170 | T=100;%SaveEvreyScenarios 171 | handles.TotalNofSce=P.TotalScenarios; 172 | if T>handles.TotalNofSce 173 | T=handles.TotalNofSce; 174 | end 175 | set(handles.SaveEveryScenarios,'String',T); 176 | set(handles.FileText,'String',[handles.file0,'.0']) 177 | set(handles.TotalScenarios,'String',handles.TotalNofSce); 178 | %set(handles.EditNumberOfScenarios,'String',handles.TotalNofSce); 179 | end 180 | handles.P=P; 181 | hanldes.B=B; 182 | % Update handles structure 183 | guidata(hObject, handles); 184 | end 185 | save([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 186 | 187 | % --- Executes on mouse press over axes background. 188 | function axes2_ButtonDownFcn(hObject, eventdata, handles) 189 | % hObject handle to axes2 (see GCBO) 190 | % eventdata reserved - to be defined in a future version of MATLAB 191 | % handles structure with handles and user data (see GUIDATA) 192 | 193 | 194 | 195 | function SaveEveryScenarios_Callback(hObject, eventdata, handles) 196 | % hObject handle to SaveEveryScenarios (see GCBO) 197 | % eventdata reserved - to be defined in a future version of MATLAB 198 | % handles structure with handles and user data (see GUIDATA) 199 | 200 | % Hints: get(hObject,'String') returns contents of SaveEveryScenarios as text 201 | % str2double(get(hObject,'String')) returns contents of SaveEveryScenarios as a double 202 | 203 | 204 | % --- Executes during object creation, after setting all properties. 205 | function SaveEveryScenarios_CreateFcn(hObject, eventdata, handles) 206 | % hObject handle to SaveEveryScenarios (see GCBO) 207 | % eventdata reserved - to be defined in a future version of MATLAB 208 | % handles empty - handles not created until after all CreateFcns called 209 | 210 | % Hint: edit controls usually have a white background on Windows. 211 | % See ISPC and COMPUTER. 212 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 213 | set(hObject,'BackgroundColor','white'); 214 | end 215 | 216 | 217 | 218 | function EditNumberOfScenarios_Callback(hObject, eventdata, handles) 219 | % hObject handle to EditNumberOfScenarios (see GCBO) 220 | % eventdata reserved - to be defined in a future version of MATLAB 221 | % handles structure with handles and user data (see GUIDATA) 222 | 223 | % Hints: get(hObject,'String') returns contents of EditNumberOfScenarios as text 224 | % str2double(get(hObject,'String')) returns contents of EditNumberOfScenarios as a double 225 | 226 | 227 | % --- Executes during object creation, after setting all properties. 228 | function EditNumberOfScenarios_CreateFcn(hObject, eventdata, handles) 229 | % hObject handle to EditNumberOfScenarios (see GCBO) 230 | % eventdata reserved - to be defined in a future version of MATLAB 231 | % handles empty - handles not created until after all CreateFcns called 232 | 233 | % Hint: edit controls usually have a white background on Windows. 234 | % See ISPC and COMPUTER. 235 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 236 | set(hObject,'BackgroundColor','white'); 237 | end 238 | 239 | 240 | % --- Executes during object creation, after setting all properties. 241 | function TotalScenarios_CreateFcn(hObject, eventdata, handles) 242 | % hObject handle to TotalScenarios (see GCBO) 243 | % eventdata reserved - to be defined in a future version of MATLAB 244 | % handles empty - handles not created until after all CreateFcns called 245 | 246 | 247 | 248 | 249 | 250 | 251 | function edit6_Callback(hObject, eventdata, handles) 252 | % hObject handle to SaveEveryScenarios (see GCBO) 253 | % eventdata reserved - to be defined in a future version of MATLAB 254 | % handles structure with handles and user data (see GUIDATA) 255 | 256 | % Hints: get(hObject,'String') returns contents of SaveEveryScenarios as text 257 | % str2double(get(hObject,'String')) returns contents of SaveEveryScenarios as a double 258 | 259 | 260 | % --- Executes during object creation, after setting all properties. 261 | function edit6_CreateFcn(hObject, eventdata, handles) 262 | % hObject handle to SaveEveryScenarios (see GCBO) 263 | % eventdata reserved - to be defined in a future version of MATLAB 264 | % handles empty - handles not created until after all CreateFcns called 265 | 266 | % Hint: edit controls usually have a white background on Windows. 267 | % See ISPC and COMPUTER. 268 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 269 | set(hObject,'BackgroundColor','white'); 270 | end 271 | -------------------------------------------------------------------------------- /SPLACE/MISC/progressbar.m: -------------------------------------------------------------------------------- 1 | function progressbar(varargin) 2 | % Description: 3 | % progressbar() provides an indication of the progress of some task using 4 | % graphics and text. Calling progressbar repeatedly will update the figure and 5 | % automatically estimate the amount of time remaining. 6 | % This implementation of progressbar is intended to be extremely simple to use 7 | % while providing a high quality user experience. 8 | % 9 | % Features: 10 | % - Can add progressbar to existing m-files with a single line of code. 11 | % - Supports multiple bars in one figure to show progress of nested loops. 12 | % - Optional labels on bars. 13 | % - Figure closes automatically when task is complete. 14 | % - Only one figure can exist so old figures don't clutter the desktop. 15 | % - Remaining time estimate is accurate even if the figure gets closed. 16 | % - Minimal execution time. Won't slow down code. 17 | % - Randomized color. When a programmer gets bored... 18 | % 19 | % Example Function Calls For Single Bar Usage: 20 | % progressbar % Initialize/reset 21 | % progressbar(0) % Initialize/reset 22 | % progressbar('Label') % Initialize/reset and label the bar 23 | % progressbar(0.5) % Update 24 | % progressbar(1) % Close 25 | % 26 | % Example Function Calls For Multi Bar Usage: 27 | % progressbar(0, 0) % Initialize/reset two bars 28 | % progressbar('A', '') % Initialize/reset two bars with one label 29 | % progressbar('', 'B') % Initialize/reset two bars with one label 30 | % progressbar('A', 'B') % Initialize/reset two bars with two labels 31 | % progressbar(0.3) % Update 1st bar 32 | % progressbar(0.3, []) % Update 1st bar 33 | % progressbar([], 0.3) % Update 2nd bar 34 | % progressbar(0.7, 0.9) % Update both bars 35 | % progressbar(1) % Close 36 | % progressbar(1, []) % Close 37 | % progressbar(1, 0.4) % Close 38 | % 39 | % Notes: 40 | % For best results, call progressbar with all zero (or all string) inputs 41 | % before any processing. This sets the proper starting time reference to 42 | % calculate time remaining. 43 | % Bar color is choosen randomly when the figure is created or reset. Clicking 44 | % the bar will cause a random color change. 45 | % 46 | % Demos: 47 | % % Single bar 48 | % m = 500; 49 | % progressbar % Init single bar 50 | % for i = 1:m 51 | % pause(0.01) % Do something important 52 | % progressbar(i/m) % Update progress bar 53 | % end 54 | % 55 | % % Simple multi bar (update one bar at a time) 56 | % m = 4; 57 | % n = 3; 58 | % p = 100; 59 | % progressbar(0,0,0) % Init 3 bars 60 | % for i = 1:m 61 | % progressbar([],0) % Reset 2nd bar 62 | % for j = 1:n 63 | % progressbar([],[],0) % Reset 3rd bar 64 | % for k = 1:p 65 | % pause(0.01) % Do something important 66 | % progressbar([],[],k/p) % Update 3rd bar 67 | % end 68 | % progressbar([],j/n) % Update 2nd bar 69 | % end 70 | % progressbar(i/m) % Update 1st bar 71 | % end 72 | % 73 | % % Fancy multi bar (use labels and update all bars at once) 74 | % m = 4; 75 | % n = 3; 76 | % p = 100; 77 | % progressbar('Monte Carlo Trials','Simulation','Component') % Init 3 bars 78 | % for i = 1:m 79 | % for j = 1:n 80 | % for k = 1:p 81 | % pause(0.01) % Do something important 82 | % % Update all bars 83 | % frac3 = k/p; 84 | % frac2 = ((j-1) + frac3) / n; 85 | % frac1 = ((i-1) + frac2) / m; 86 | % progressbar(frac1, frac2, frac3) 87 | % end 88 | % end 89 | % end 90 | % 91 | % Author: 92 | % Steve Hoelzer 93 | % 94 | % Revisions: 95 | % 2002-Feb-27 Created function 96 | % 2002-Mar-19 Updated title text order 97 | % 2002-Apr-11 Use floor instead of round for percentdone 98 | % 2002-Jun-06 Updated for speed using patch (Thanks to waitbar.m) 99 | % 2002-Jun-19 Choose random patch color when a new figure is created 100 | % 2002-Jun-24 Click on bar or axes to choose new random color 101 | % 2002-Jun-27 Calc time left, reset progress bar when fractiondone == 0 102 | % 2002-Jun-28 Remove extraText var, add position var 103 | % 2002-Jul-18 fractiondone input is optional 104 | % 2002-Jul-19 Allow position to specify screen coordinates 105 | % 2002-Jul-22 Clear vars used in color change callback routine 106 | % 2002-Jul-29 Position input is always specified in pixels 107 | % 2002-Sep-09 Change order of title bar text 108 | % 2003-Jun-13 Change 'min' to 'm' because of built in function 'min' 109 | % 2003-Sep-08 Use callback for changing color instead of string 110 | % 2003-Sep-10 Use persistent vars for speed, modify titlebarstr 111 | % 2003-Sep-25 Correct titlebarstr for 0% case 112 | % 2003-Nov-25 Clear all persistent vars when percentdone = 100 113 | % 2004-Jan-22 Cleaner reset process, don't create figure if percentdone = 100 114 | % 2004-Jan-27 Handle incorrect position input 115 | % 2004-Feb-16 Minimum time interval between updates 116 | % 2004-Apr-01 Cleaner process of enforcing minimum time interval 117 | % 2004-Oct-08 Seperate function for timeleftstr, expand to include days 118 | % 2004-Oct-20 Efficient if-else structure for sec2timestr 119 | % 2006-Sep-11 Width is a multiple of height (don't stretch on widescreens) 120 | % 2010-Sep-21 Major overhaul to support multiple bars and add labels 121 | % 122 | 123 | persistent progfig progdata lastupdate 124 | 125 | % Get inputs 126 | if nargin > 0 127 | input = varargin; 128 | ninput = nargin; 129 | else 130 | % If no inputs, init with a single bar 131 | input = {0}; 132 | ninput = 1; 133 | end 134 | 135 | % If task completed, close figure and clear vars, then exit 136 | if input{1} == 1 137 | if ishandle(progfig) 138 | delete(progfig) % Close progress bar 139 | end 140 | clear progfig progdata lastupdate % Clear persistent vars 141 | drawnow 142 | return 143 | end 144 | 145 | % Init reset flag 146 | resetflag = false; 147 | 148 | % Set reset flag if first input is a string 149 | if ischar(input{1}) 150 | resetflag = true; 151 | end 152 | 153 | % Set reset flag if all inputs are zero 154 | if input{1} == 0 155 | % If the quick check above passes, need to check all inputs 156 | if all([input{:}] == 0) && (length([input{:}]) == ninput) 157 | resetflag = true; 158 | end 159 | end 160 | 161 | % Set reset flag if more inputs than bars 162 | if ninput > length(progdata) 163 | resetflag = true; 164 | end 165 | 166 | % If reset needed, close figure and forget old data 167 | if resetflag 168 | if ishandle(progfig) 169 | delete(progfig) % Close progress bar 170 | end 171 | progfig = []; 172 | progdata = []; % Forget obsolete data 173 | end 174 | 175 | % Create new progress bar if needed 176 | if ishandle(progfig) 177 | else % This strange if-else works when progfig is empty (~ishandle() does not) 178 | 179 | % Define figure size and axes padding for the single bar case 180 | height = 0.03; 181 | width = height * 8; 182 | hpad = 0.02; 183 | vpad = 0.25; 184 | 185 | % Figure out how many bars to draw 186 | nbars = max(ninput, length(progdata)); 187 | 188 | % Adjust figure size and axes padding for number of bars 189 | heightfactor = (1 - vpad) * nbars + vpad; 190 | height = height * heightfactor; 191 | vpad = vpad / heightfactor; 192 | 193 | % Initialize progress bar figure 194 | left = (1 - width) / 2; 195 | bottom = (1 - height) / 2; 196 | progfig = figure(... 197 | 'Units', 'normalized',... 198 | 'Position', [left bottom width height],... 199 | 'NumberTitle', 'off',... 200 | 'Resize', 'off',... 201 | 'MenuBar', 'none' ); 202 | 203 | % Initialize axes, patch, and text for each bar 204 | left = hpad; 205 | width = 1 - 2*hpad; 206 | vpadtotal = vpad * (nbars + 1); 207 | height = (1 - vpadtotal) / nbars; 208 | for ndx = 1:nbars 209 | % Create axes, patch, and text 210 | bottom = vpad + (vpad + height) * (nbars - ndx); 211 | progdata(ndx).progaxes = axes( ... 212 | 'Position', [left bottom width height], ... 213 | 'XLim', [0 1], ... 214 | 'YLim', [0 1], ... 215 | 'Box', 'on', ... 216 | 'ytick', [], ... 217 | 'xtick', [] ); 218 | progdata(ndx).progpatch = patch( ... 219 | 'XData', [0 0 0 0], ... 220 | 'YData', [0 0 1 1] ); 221 | progdata(ndx).progtext = text(0.99, 0.5, '', ... 222 | 'HorizontalAlignment', 'Right', ... 223 | 'FontUnits', 'Normalized', ... 224 | 'FontSize', 0.7 ); 225 | progdata(ndx).proglabel = text(0.01, 0.5, '', ... 226 | 'HorizontalAlignment', 'Left', ... 227 | 'FontUnits', 'Normalized', ... 228 | 'FontSize', 0.7 ); 229 | if ischar(input{ndx}) 230 | set(progdata(ndx).proglabel, 'String', input{ndx}) 231 | input{ndx} = 0; 232 | end 233 | 234 | % Set callbacks to change color on mouse click 235 | set(progdata(ndx).progaxes, 'ButtonDownFcn', {@changecolor, progdata(ndx).progpatch}) 236 | set(progdata(ndx).progpatch, 'ButtonDownFcn', {@changecolor, progdata(ndx).progpatch}) 237 | set(progdata(ndx).progtext, 'ButtonDownFcn', {@changecolor, progdata(ndx).progpatch}) 238 | set(progdata(ndx).proglabel, 'ButtonDownFcn', {@changecolor, progdata(ndx).progpatch}) 239 | 240 | % Pick a random color for this patch 241 | changecolor([], [], progdata(ndx).progpatch) 242 | 243 | % Set starting time reference 244 | if ~isfield(progdata(ndx), 'starttime') || isempty(progdata(ndx).starttime) 245 | progdata(ndx).starttime = clock; 246 | end 247 | end 248 | 249 | % Set time of last update to ensure a redraw 250 | lastupdate = clock - 1; 251 | 252 | end 253 | 254 | % Process inputs and update state of progdata 255 | for ndx = 1:ninput 256 | if ~isempty(input{ndx}) 257 | progdata(ndx).fractiondone = input{ndx}; 258 | progdata(ndx).clock = clock; 259 | end 260 | end 261 | 262 | % Enforce a minimum time interval between graphics updates 263 | myclock = clock; 264 | if abs(myclock(6) - lastupdate(6)) < 0.01 % Could use etime() but this is faster 265 | return 266 | end 267 | 268 | % Update progress patch 269 | for ndx = 1:length(progdata) 270 | set(progdata(ndx).progpatch, 'XData', ... 271 | [0, progdata(ndx).fractiondone, progdata(ndx).fractiondone, 0]) 272 | end 273 | 274 | % Update progress text if there is more than one bar 275 | if length(progdata) > 1 276 | for ndx = 1:length(progdata) 277 | set(progdata(ndx).progtext, 'String', ... 278 | sprintf('%1d%%', floor(100*progdata(ndx).fractiondone))) 279 | end 280 | end 281 | 282 | % Update progress figure title bar 283 | if progdata(1).fractiondone > 0 284 | runtime = etime(progdata(1).clock, progdata(1).starttime); 285 | timeleft = runtime / progdata(1).fractiondone - runtime; 286 | timeleftstr = sec2timestr(timeleft); 287 | titlebarstr = sprintf('%2d%% %s remaining', ... 288 | floor(100*progdata(1).fractiondone), timeleftstr); 289 | else 290 | titlebarstr = ' 0%'; 291 | end 292 | set(progfig, 'Name', titlebarstr) 293 | 294 | % Force redraw to show changes 295 | drawnow 296 | 297 | % Record time of this update 298 | lastupdate = clock; 299 | 300 | 301 | % ------------------------------------------------------------------------------ 302 | function changecolor(h, e, progpatch) %#ok 303 | % Change the color of the progress bar patch 304 | 305 | % Prevent color from being too dark or too light 306 | colormin = 1.5; 307 | colormax = 2.8; 308 | 309 | thiscolor = rand(1, 3); 310 | while (sum(thiscolor) < colormin) || (sum(thiscolor) > colormax) 311 | thiscolor = rand(1, 3); 312 | end 313 | 314 | set(progpatch, 'FaceColor', thiscolor) 315 | 316 | 317 | % ------------------------------------------------------------------------------ 318 | function timestr = sec2timestr(sec) 319 | % Convert a time measurement from seconds into a human readable string. 320 | 321 | % Convert seconds to other units 322 | w = floor(sec/604800); % Weeks 323 | sec = sec - w*604800; 324 | d = floor(sec/86400); % Days 325 | sec = sec - d*86400; 326 | h = floor(sec/3600); % Hours 327 | sec = sec - h*3600; 328 | m = floor(sec/60); % Minutes 329 | sec = sec - m*60; 330 | s = floor(sec); % Seconds 331 | 332 | % Create time string 333 | if w > 0 334 | if w > 9 335 | timestr = sprintf('%d week', w); 336 | else 337 | timestr = sprintf('%d week, %d day', w, d); 338 | end 339 | elseif d > 0 340 | if d > 9 341 | timestr = sprintf('%d day', d); 342 | else 343 | timestr = sprintf('%d day, %d hr', d, h); 344 | end 345 | elseif h > 0 346 | if h > 9 347 | timestr = sprintf('%d hr', h); 348 | else 349 | timestr = sprintf('%d hr, %d min', h, m); 350 | end 351 | elseif m > 0 352 | if m > 9 353 | timestr = sprintf('%d min', m); 354 | else 355 | timestr = sprintf('%d min, %d sec', m, s); 356 | end 357 | else 358 | timestr = sprintf('%d sec', s); 359 | end 360 | -------------------------------------------------------------------------------- /NETWORKS/Anytown_Walski1987.inp: -------------------------------------------------------------------------------- 1 | [TITLE] 2 | ANYTOWN example 3 | 4 | [JUNCTIONS] 5 | ;ID Elev Demand Pattern 6 | 1 20 500 1 ; 7 | 2 50 200 1 ; 8 | 3 50 200 1 ; 9 | 4 50 600 1 ; 10 | 5 80 600 1 ; 11 | 6 80 600 1 ; 12 | 7 80 600 1 ; 13 | 8 80 400 1 ; 14 | 9 120 400 1 ; 15 | 10 120 400 1 ; 16 | 11 120 400 1 ; 17 | 12 50 500 1 ; 18 | 13 50 500 1 ; 19 | 14 50 500 1 ; 20 | 15 50 500 1 ; 21 | 16 120 400 1 ; 22 | 17 120 1000 1 ; 23 | 18 50 500 1 ; 24 | 19 50 1000 1 ; 25 | 20 20 0 1 ; 26 | 21 50 0 1 ; 27 | 22 120 0 1 ; 28 | 29 | [RESERVOIRS] 30 | ;ID Head Pattern 31 | 40 10 ; 32 | 33 | [TANKS] 34 | ;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve 35 | 41 215 10 10 35 32.65 0 ; 36 | 42 215 10 10 35 32.65 0 ; 37 | 38 | [PIPES] 39 | ;ID Node1 Node2 Length Diameter Roughness MinorLoss Status 40 | 1 1 2 12000 12 120 0 Open ;Res 41 | 2 1 12 12000 12 70 0 Open ;city 42 | 3 1 13 12000 16 70 0 Open ;city 43 | 4 1 20 100 30 130 0 Open ;city 44 | 5 2 3 6000 10 120 0 Open ;Res 45 | 6 2 4 9000 10 120 0 Open ;Res 46 | 7 2 13 9000 12 70 0 Open ;Res 47 | 8 2 14 6000 10 120 0 Open ;Res 48 | 9 3 4 6000 10 120 0 Open ;Res 49 | 11 4 8 12000 8 120 0 Open ;Res 50 | 12 4 15 6000 10 120 0 Open ;Res 51 | 17 8 9 12000 8 120 0 Open ;Res 52 | 18 8 15 6000 10 120 0 Open ;Res 53 | 19 8 16 6000 8 120 0 Open ;Res 54 | 20 8 17 6000 8 120 0 Open ;Res 55 | 21 9 10 6000 8 120 0 Open ;Res 56 | 22 10 11 6000 8 120 0 Open ;Res 57 | 23 10 17 6000 10 120 0 Open ;Res 58 | 24 11 12 6000 8 120 0 Open ;Res 59 | 26 12 17 6000 10 120 0 Open ;Res 60 | 27 12 18 6000 8 70 0 Open ;city 61 | 28 13 14 6000 12 70 0 Open ;city 62 | 29 13 18 6000 12 70 0 Open ;city 63 | 30 13 19 6000 10 70 0 Open ;city 64 | 31 14 15 6000 12 70 0 Open ;city 65 | 32 14 19 6000 10 70 0 Open ;city 66 | 33 14 21 100 12 120 0 Open ;city 67 | 34 15 16 6000 10 70 0 Open ;city 68 | 35 15 19 6000 10 70 0 Open ;city 69 | 36 16 17 6000 8 120 0 Open ;Res 70 | 37 16 18 6000 12 70 0 Open ;city 71 | 38 16 19 6000 10 70 0 Open ;city 72 | 39 17 18 6000 8 120 0 Open ;Res 73 | 40 17 22 100 12 120 0 Open ;Res 74 | 41 18 19 6000 10 70 0 Open ;city 75 | 142 21 41 1 12 120 0 Open ;city 76 | 143 22 42 1 12 120 0 Open ;Res 77 | 110 4 5 6000 0.0001 130 0 Open ;New 78 | 113 5 6 6000 0.0001 130 0 Open ;New 79 | 114 6 7 6000 0.0001 130 0 Open ;New 80 | 115 6 8 6000 0.0001 130 0 Open ;New 81 | 116 7 8 6000 0.0001 130 0 Open ;New 82 | 125 11 17 9000 0.0001 130 0 Open ;New 83 | 84 | [PUMPS] 85 | ;ID Node1 Node2 Parameters 86 | 78 40 20 HEAD 2 PATTERN 2 ; 87 | 79 40 20 HEAD 2 PATTERN 3 ; 88 | 80 40 20 HEAD 2 PATTERN 4 ; 89 | 90 | [VALVES] 91 | ;ID Node1 Node2 Diameter Type Setting MinorLoss 92 | 93 | [TAGS] 94 | 95 | [DEMANDS] 96 | ;Junction Demand Pattern Category 97 | 98 | [STATUS] 99 | ;ID Status/Setting 100 | 101 | [PATTERNS] 102 | ;ID Multipliers 103 | ;Daily water use pattern 104 | 1 1.0 1.0 1.0 0.9 0.9 0.9 105 | 1 0.7 0.7 0.7 0.6 0.6 0.6 106 | 1 1.2 1.2 1.2 1.3 1.3 1.3 107 | 1 1.2 1.2 1.2 1.1 1.1 1.1 108 | ;Daily Operating Pump 109 | 2 0 0 0 0 0 0 110 | 2 0 0 0 0 0 0 111 | 2 0 0 0 0 0 0 112 | 2 0 0 0 0 0 0 113 | ;Daily Alternate Pump 114 | 3 0 0 0 0 0 0 115 | 3 0 0 0 0 0 0 116 | 3 0 0 0 0 0 0 117 | 3 0 0 0 0 0 0 118 | ;Daily Alternate Pump 119 | 4 0 0 0 0 0 0 120 | 4 0 0 0 0 0 0 121 | 4 0 0 0 0 0 0 122 | 4 0 0 0 0 0 0 123 | 124 | [CURVES] 125 | ;ID X-Value Y-Value 126 | ;PUMP: ID X-Value Y-Value 127 | 2 0. 300 128 | 2 2000 292 129 | 2 4000 270 130 | 2 6000 230 131 | 2 8000 181 132 | ;PUMP: ID flow efficiency 133 | E1 0. 0 134 | E1 2000 50 135 | E1 4000 65 136 | E1 6000 55 137 | E1 8000 40 138 | 139 | [CONTROLS] 140 | 141 | [RULES] 142 | 143 | [ENERGY] 144 | Global Efficiency 75 145 | Global Price 0 146 | Demand Charge 0 147 | Pump 78 Efficiency E1 148 | Pump 79 Efficiency E1 149 | Pump 80 Efficiency E1 150 | 151 | [EMITTERS] 152 | ;Junction Coefficient 153 | 154 | [QUALITY] 155 | ;Node InitQual 156 | 157 | [SOURCES] 158 | ;Node Type Quality Pattern 159 | 160 | [REACTIONS] 161 | ;Type Pipe/Tank Coefficient 162 | 163 | 164 | [REACTIONS] 165 | Order Bulk 1 166 | Order Tank 1 167 | Order Wall 1 168 | Global Bulk 0 169 | Global Wall 0 170 | Limiting Potential 0 171 | Roughness Correlation 0 172 | 173 | [MIXING] 174 | ;Tank Model 175 | 176 | [TIMES] 177 | Duration 24:00 178 | Hydraulic Timestep 0:01 179 | Quality Timestep 0:01 180 | Pattern Timestep 1:00 181 | Pattern Start 0:00 182 | Report Timestep 1:00 183 | Report Start 0:00 184 | Start ClockTime 12 am 185 | Statistic NONE 186 | 187 | [REPORT] 188 | Status No 189 | Summary No 190 | Page 0 191 | 192 | [OPTIONS] 193 | Units GPM 194 | Headloss H-W 195 | Specific Gravity 1 196 | Viscosity 1 197 | Trials 40 198 | Accuracy 0.001 199 | CHECKFREQ 2 200 | MAXCHECK 10 201 | DAMPLIMIT 0 202 | Unbalanced Continue 10 203 | Pattern 1 204 | Demand Multiplier 1.0 205 | Emitter Exponent 0.5 206 | Quality NONE mg/L 207 | Diffusivity 1.0 208 | Tolerance 0.01 209 | 210 | [COORDINATES] 211 | ;Node X-Coord Y-Coord 212 | 1 7682.33 3371.15 213 | 2 7633.71 5737.44 214 | 3 7520.26 7293.35 215 | 4 6175.04 7568.88 216 | 5 5591.57 8460.29 217 | 6 4100.49 8071.31 218 | 7 3192.87 7763.37 219 | 8 3321.19 6696.55 220 | 9 1305.62 4850.97 221 | 10 2317.45 3588.20 222 | 11 3701.63 2892.06 223 | 12 4846.03 3354.94 224 | 13 6450.57 4424.64 225 | 14 6466.77 5769.85 226 | 15 5094.45 6482.09 227 | 16 4017.86 5615.96 228 | 17 3005.49 4292.43 229 | 18 4846.03 4440.84 230 | 19 5332.25 5332.25 231 | 20 8544.18 3371.15 232 | 21 6094.00 6499.19 233 | 22 2422.68 4519.09 234 | 40 8700.60 3371.15 235 | 41 6094.00 6600.19 236 | 42 2422.68 4700.09 237 | 238 | [VERTICES] 239 | ;Link X-Coord Y-Coord 240 | 241 | [LABELS] 242 | ;X-Coord Y-Coord Label & Anchor Node 243 | 244 | [BACKDROP] 245 | DIMENSIONS 935.87 2613.65 9070.35 8738.70 246 | UNITS None 247 | FILE 248 | OFFSET 0.00 0.00 249 | 250 | [END] 251 | -------------------------------------------------------------------------------- /SPLACE/OPTIMIZATION/Exhaustive/Exhaustive.m: -------------------------------------------------------------------------------- 1 | %{ 2 | Copyright 2013 KIOS Research Center for Intelligent Systems and Networks, University of Cyprus (www.kios.org.cy) 3 | 4 | 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"); 5 | You may not use this work except in compliance with the Licence. 6 | You may obtain a copy of the Licence at: 7 | 8 | http://ec.europa.eu/idabc/eupl 9 | 10 | Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the Licence for the specific language governing permissions and limitations under the Licence. 13 | %} 14 | 15 | function varargout = Exhaustive(varargin) 16 | % EXHAUSTIVE MATLAB code for Exhaustive.fig 17 | % EXHAUSTIVE, by itself, creates a new EXHAUSTIVE or raises the existing 18 | % singleton*. 19 | % 20 | % H = EXHAUSTIVE returns the handle to a new EXHAUSTIVE or the handle to 21 | % the existing singleton*. 22 | % 23 | % EXHAUSTIVE('CALLBACK',hObject,eventData,handles,...) calls the local 24 | % function named CALLBACK in EXHAUSTIVE.M with the given input arguments. 25 | % 26 | % EXHAUSTIVE('Property','Value',...) creates a new EXHAUSTIVE or raises the 27 | % existing singleton*. Starting from the left, property value pairs are 28 | % applied to the GUI before Exhaustive_OpeningFcn gets called. An 29 | % unrecognized property name or invalid value makes property application 30 | % stop. All inputs are passed to Exhaustive_OpeningFcn via varargin. 31 | % 32 | % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 33 | % instance to run (singleton)". 34 | % 35 | % See also: GUIDE, GUIDATA, GUIHANDLES 36 | 37 | % Edit the above text to modify the response to help Exhaustive 38 | 39 | % Last Modified by GUIDE v2.5 22-May-2013 23:24:52 40 | 41 | % Begin initialization code - DO NOT EDIT 42 | gui_Singleton = 1; 43 | gui_State = struct('gui_Name', mfilename, ... 44 | 'gui_Singleton', gui_Singleton, ... 45 | 'gui_OpeningFcn', @Exhaustive_OpeningFcn, ... 46 | 'gui_OutputFcn', @Exhaustive_OutputFcn, ... 47 | 'gui_LayoutFcn', [] , ... 48 | 'gui_Callback', []); 49 | if nargin && ischar(varargin{1}) 50 | gui_State.gui_Callback = str2func(varargin{1}); 51 | end 52 | 53 | if nargout 54 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 55 | else 56 | gui_mainfcn(gui_State, varargin{:}); 57 | end 58 | % End initialization code - DO NOT EDIT 59 | 60 | 61 | % --- Executes just before Exhaustive is made visible. 62 | function Exhaustive_OpeningFcn(hObject, eventdata, handles, varargin) 63 | % This function has no output args, see OutputFcn. 64 | % hObject handle to figure 65 | % eventdata reserved - to be defined in a future version of MATLAB 66 | % handles structure with handles and user data (see GUIDATA) 67 | % varargin command line arguments to Exhaustive (see VARARGIN) 68 | 69 | % Choose default command line output for Exhaustive 70 | handles.output = hObject; 71 | 72 | % UIWAIT makes Exhaustive wait for user response (see UIRESUME) 73 | % uiwait(handles.figure1); 74 | 75 | set(handles.figure1,'name','Solve Sensor Placement'); 76 | position = get(handles.figure1,'Position'); 77 | % set(handles.figure1,'Position',[103.8 26 49 31]) 78 | 79 | handles.file0 = varargin{1}.file0; 80 | handles.B = varargin{1}.B; 81 | handles.LoadText = varargin{1}.LoadText; 82 | handles.SplaceTable = varargin{1}.SplaceTable; 83 | handles.export_sensors = varargin{1}.export_sensors; 84 | handles.axes1 = varargin{1}.axes1; 85 | 86 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 87 | 88 | set(handles.LoadImpactMatrix,'enable','off'); 89 | set(handles.Solve,'enable','off'); 90 | 91 | if exist([pathname,handles.file0,'.0'],'file')==2 92 | if ~isempty([handles.file0,'.0']) 93 | load([pathname,handles.file0,'.0'],'-mat'); 94 | else 95 | B.InputFile=handles.B.InputFile; 96 | end 97 | else 98 | B.InputFile=[]; 99 | end 100 | 101 | if ~strcmp(handles.B.InputFile,B.InputFile) 102 | set(handles.FileText0,'String','') 103 | else 104 | set(handles.FileText0,'String',[handles.file0,'.0']) 105 | if exist([pathname,handles.file0,'.w'],'file')==2 106 | set(handles.Solve,'enable','on'); 107 | if exist([pathname,handles.file0,'.w'],'file')==2 108 | set(handles.FileTextW,'String',[handles.file0,'.w']); 109 | end 110 | set(handles.LoadImpactMatrix,'enable','on'); 111 | else 112 | set(handles.LoadImpactMatrix,'enable','on'); 113 | end 114 | end 115 | 116 | handles.pp=DefaultSolveParameters(hObject,handles); 117 | 118 | % Update handles structure 119 | guidata(hObject, handles); 120 | 121 | function pp=DefaultSolveParameters(hObject,handles) 122 | pp.solutionMethod=0; 123 | pp.numberOfSensors='1:3'; 124 | set(handles.numberOfSensors,'String',pp.numberOfSensors); 125 | 126 | % Update handles structure 127 | guidata(hObject, handles); 128 | 129 | % --- Outputs from this function are returned to the command line. 130 | function varargout = Exhaustive_OutputFcn(hObject, eventdata, handles) 131 | % varargout cell array for returning output args (see VARARGOUT); 132 | % hObject handle to figure 133 | % eventdata reserved - to be defined in a future version of MATLAB 134 | % handles structure with handles and user data (see GUIDATA) 135 | 136 | % Get default command line output from handles structure 137 | varargout{1} = handles.output; 138 | 139 | function numberOfSensors_Callback(hObject, eventdata, handles) 140 | % hObject handle to numberOfSensors (see GCBO) 141 | % eventdata reserved - to be defined in a future version of MATLAB 142 | % handles structure with handles and user data (see GUIDATA) 143 | 144 | % Hints: get(hObject,'String') returns contents of numberOfSensors as text 145 | % str2double(get(hObject,'String')) returns contents of numberOfSensors as a double 146 | 147 | 148 | % --- Executes during object creation, after setting all properties. 149 | function numberOfSensors_CreateFcn(hObject, eventdata, handles) 150 | % hObject handle to numberOfSensors (see GCBO) 151 | % eventdata reserved - to be defined in a future version of MATLAB 152 | % handles empty - handles not created until after all CreateFcns called 153 | 154 | % Hint: edit controls usually have a white background on Windows. 155 | % See ISPC and COMPUTER. 156 | if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) 157 | set(hObject,'BackgroundColor','white'); 158 | end 159 | 160 | 161 | % --- Executes on button press in Solve. 162 | function Solve_Callback(hObject, eventdata, handles) 163 | % hObject handle to Solve (see GCBO) 164 | % eventdata reserved - to be defined in a future version of MATLAB 165 | % handles structure with handles and user data (see GUIDATA) 166 | 167 | [errorCode,handles.pp] = CheckForError(hObject,handles); 168 | if errorCode 169 | return; 170 | end 171 | handles.pp.numberOfSensors=get(handles.numberOfSensors,'String'); 172 | 173 | load([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 174 | msg=[msg;{'>>Running..'}]; 175 | 176 | set(handles.LoadText,'String',msg); 177 | set(handles.LoadText,'Value',length(msg)); 178 | 179 | if sum(str2num(handles.pp.numberOfSensors)>handles.B.NodeCount)>0 180 | msg=[msg;{'>>Give number of sensors.'}]; 181 | set(handles.LoadText,'String',msg); 182 | set(handles.LoadText,'Value',length(msg)); 183 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 184 | return 185 | end 186 | set(handles.figure1,'visible','off'); 187 | 188 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 189 | % Method 190 | ExhaustiveOptimization(handles); 191 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 192 | 193 | set(handles.SplaceTable,'enable','on'); 194 | set(handles.SplaceTable,'String',''); 195 | 196 | set(handles.LoadText,'Value',1); 197 | msg=[msg;{'>>Solve Sensor Placement.'}]; 198 | set(handles.LoadText,'String',msg); 199 | set(handles.LoadText,'Value',length(msg)); 200 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 201 | 202 | load([pathname,handles.file0,'.y0'],'Y', '-mat'); %Evolutionary method 203 | 204 | set(handles.SplaceTable,'Foregroundcolor','b'); 205 | set(handles.SplaceTable,'fontsize',8);%10 206 | 207 | w=[{'------S-PLACE------ [Exhaustive Method]'};{' '}]; 208 | set(handles.SplaceTable,'visible','on'); 209 | a=str2num(handles.pp.numberOfSensors); 210 | u=1; 211 | w=[w;{['------Sensors-Placement: ',num2str(a(1))]}]; 212 | 213 | i=1;k=1;pp=1; 214 | while i1 224 | for t=2:length(ss1) 225 | SensorsSS = [SensorsSS,' ',num2str(handles.B.NodeNameID{ss1(t)})]; 226 | end 227 | end 228 | w=[w;{['mean = ',num2str(sprintf('%10.2f',f1)),' max = ',num2str(sprintf('%10.2f',f2)),' NodesID: ',SensorsSS]}]; 229 | set(handles.SplaceTable,'Value',length(w)); 230 | set(handles.SplaceTable,'String',w); 231 | else 232 | u=u+1; 233 | pp=0; 234 | i=i-1; 235 | w=[w;{['------Sensors-Placement: ',num2str(a(u))]}]; 236 | end 237 | i=i+1;pp=pp+1; 238 | end 239 | 240 | msg=[msg;{'>>Exhaustive algorithm was succesfull.'}]; 241 | set(handles.LoadText,'String',msg); 242 | set(handles.LoadText,'Value',length(msg)); 243 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 244 | save([pwd,'\RESULTS\','w.report'],'w','-mat'); 245 | set(handles.export_sensors,'visible','on'); 246 | 247 | 248 | 249 | function [errorCode,pp] = CheckForError(hObject,handles) 250 | errorCode=0; 251 | pp.numberOfSensors=str2num(get(handles.numberOfSensors,'String')); 252 | 253 | if ~length(pp.numberOfSensors) || sum(pp.numberOfSensors<0) || sum((pp.numberOfSensors)>handles.B.NodeCount)>0 254 | msgbox(' Give Number of Sensors', 'Error', 'modal') 255 | errorCode=1; 256 | return 257 | end 258 | 259 | % Update handles structure 260 | guidata(hObject, handles); 261 | 262 | % --- Executes on button press in DefaultParameters. 263 | function DefaultParameters_Callback(hObject, eventdata, handles) 264 | % hObject handle to DefaultParameters (see GCBO) 265 | % eventdata reserved - to be defined in a future version of MATLAB 266 | % handles structure with handles and user data (see GUIDATA) 267 | 268 | DefaultSolveParameters(hObject,handles); 269 | 270 | 271 | % --- Executes on button press in LoadImpactMatrix. 272 | function LoadImpactMatrix_Callback(hObject, eventdata, handles) 273 | % hObject handle to LoadImpactMatrix (see GCBO) 274 | % eventdata reserved - to be defined in a future version of MATLAB 275 | % handles structure with handles and user data (see GUIDATA) 276 | 277 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 278 | [fileW,pathNM] = uigetfile([pathname,'*.w'],'Select the MATLAB *.w file'); 279 | if length(pathNM)~=1 280 | pathname=pathNM; 281 | end 282 | 283 | fileW=fileW(1:end-2); 284 | if isnumeric(fileW) 285 | fileW=[]; 286 | end 287 | if ~isempty((fileW)) 288 | load([pathname,fileW,'.w'],'-mat'); 289 | handles.fileW=fileW; 290 | if ~strcmp(handles.file0,handles.fileW) 291 | set(handles.Solve,'enable','off'); 292 | msgbox(' Impact matrix is not on this input file','Error','modal'); 293 | load([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 294 | msg=[msg;{['>>Wrong Impact Matrix FileW "',fileW,'"']}]; 295 | set(handles.LoadText,'String',msg); 296 | set(handles.LoadText,'Value',length(msg)); 297 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 298 | set(handles.FileTextW,'String','') 299 | else 300 | set(handles.Solve,'enable','on'); 301 | set(handles.FileTextW,'String',[handles.file0,'.w']); 302 | end 303 | % Update handles structure 304 | guidata(hObject, handles); 305 | end 306 | save([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 307 | 308 | % --- Executes on button press in LoadScenarios. 309 | function LoadScenarios_Callback(hObject, eventdata, handles) 310 | % hObject handle to LoadScenarios (see GCBO) 311 | % eventdata reserved - to be defined in a future version of MATLAB 312 | % handles structure with handles and user data (see GUIDATA) 313 | 314 | load([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 315 | [file0,pathNM] = uigetfile([pathname,'*.0'],'Select the MATLAB *.0 file'); 316 | if length(pathNM)~=1 317 | pathname=pathNM; 318 | end 319 | 320 | file0=file0(1:end-2); 321 | if isnumeric(file0) 322 | file0=[]; 323 | end 324 | if ~isempty((file0)) 325 | load([pathname,file0,'.0'],'-mat');%clc; 326 | handles.file0=file0; 327 | if ~strcmp(handles.B.InputFile,B.InputFile) 328 | set(handles.Solve,'enable','off'); 329 | set(handles.LoadImpactMatrix,'enable','off'); 330 | load([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 331 | msg=[msg;{['>>Wrong File0 "',file0,'"']}]; 332 | set(handles.LoadText,'String',msg); 333 | set(handles.LoadText,'Value',length(msg)); 334 | save([pwd,'\RESULTS\','ComWind.messsages'],'msg','-mat'); 335 | set(handles.FileText0,'String','') 336 | else 337 | set(handles.LoadImpactMatrix,'enable','on'); 338 | set(handles.Solve,'enable','off'); 339 | set(handles.FileText0,'String',[handles.file0,'.0']); 340 | end 341 | handles.P=P; 342 | hanldes.B=B; 343 | % Update handles structure 344 | guidata(hObject, handles); 345 | end 346 | save([pwd,'\RESULTS\','pathname.File'],'pathname','-mat'); 347 | -------------------------------------------------------------------------------- /NETWORKS/Net2_Rossman2000.inp: -------------------------------------------------------------------------------- 1 | [TITLE] 2 | EPANET Example Network 2 3 | Example of modeling a 55-hour fluoride tracer study. 4 | Measured fluoride data is contained in the file Net2-FL.dat 5 | and should be registered with the project to produce a 6 | Calibration Report (select Calibration Data from the Project 7 | menu). 8 | 9 | [JUNCTIONS] 10 | ;ID Elev Demand Pattern 11 | 1 50 -694.4 2 ; 12 | 2 100 8 ; 13 | 3 60 14 ; 14 | 4 60 8 ; 15 | 5 100 8 ; 16 | 6 125 5 ; 17 | 7 160 4 ; 18 | 8 110 9 ; 19 | 9 180 14 ; 20 | 10 130 5 ; 21 | 11 185 34.78 ; 22 | 12 210 16 ; 23 | 13 210 2 ; 24 | 14 200 2 ; 25 | 15 190 2 ; 26 | 16 150 20 ; 27 | 17 180 20 ; 28 | 18 100 20 ; 29 | 19 150 5 ; 30 | 20 170 19 ; 31 | 21 150 16 ; 32 | 22 200 10 ; 33 | 23 230 8 ; 34 | 24 190 11 ; 35 | 25 230 6 ; 36 | 27 130 8 ; 37 | 28 110 0 ; 38 | 29 110 7 ; 39 | 30 130 3 ; 40 | 31 190 17 ; 41 | 32 110 17 ; 42 | 33 180 1.5 ; 43 | 34 190 1.5 ; 44 | 35 110 0 ; 45 | 36 110 1 ; 46 | 47 | [RESERVOIRS] 48 | ;ID Head Pattern 49 | 50 | [TANKS] 51 | ;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve 52 | 26 235 56.7 50 70 50 0 ; 53 | 54 | [PIPES] 55 | ;ID Node1 Node2 Length Diameter Roughness MinorLoss Status 56 | 1 1 2 2400 12 100 0 Open ; 57 | 2 2 5 800 12 100 0 Open ; 58 | 3 2 3 1300 8 100 0 Open ; 59 | 4 3 4 1200 8 100 0 Open ; 60 | 5 4 5 1000 12 100 0 Open ; 61 | 6 5 6 1200 12 100 0 Open ; 62 | 7 6 7 2700 12 100 0 Open ; 63 | 8 7 8 1200 12 140 0 Open ; 64 | 9 7 9 400 12 100 0 Open ; 65 | 10 8 10 1000 8 140 0 Open ; 66 | 11 9 11 700 12 100 0 Open ; 67 | 12 11 12 1900 12 100 0 Open ; 68 | 13 12 13 600 12 100 0 Open ; 69 | 14 13 14 400 12 100 0 Open ; 70 | 15 14 15 300 12 100 0 Open ; 71 | 16 13 16 1500 8 100 0 Open ; 72 | 17 15 17 1500 8 100 0 Open ; 73 | 18 16 17 600 8 100 0 Open ; 74 | 19 17 18 700 12 100 0 Open ; 75 | 20 18 32 350 12 100 0 Open ; 76 | 21 16 19 1400 8 100 0 Open ; 77 | 22 14 20 1100 12 100 0 Open ; 78 | 23 20 21 1300 8 100 0 Open ; 79 | 24 21 22 1300 8 100 0 Open ; 80 | 25 20 22 1300 8 100 0 Open ; 81 | 26 24 23 600 12 100 0 Open ; 82 | 27 15 24 250 12 100 0 Open ; 83 | 28 23 25 300 12 100 0 Open ; 84 | 29 25 26 200 12 100 0 Open ; 85 | 30 25 31 600 12 100 0 Open ; 86 | 31 31 27 400 8 100 0 Open ; 87 | 32 27 29 400 8 100 0 Open ; 88 | 34 29 28 700 8 100 0 Open ; 89 | 35 22 33 1000 8 100 0 Open ; 90 | 36 33 34 400 8 100 0 Open ; 91 | 37 32 19 500 8 100 0 Open ; 92 | 38 29 35 500 8 100 0 Open ; 93 | 39 35 30 1000 8 100 0 Open ; 94 | 40 28 35 700 8 100 0 Open ; 95 | 41 28 36 300 8 100 0 Open ; 96 | 97 | [PUMPS] 98 | ;ID Node1 Node2 Parameters 99 | 100 | [VALVES] 101 | ;ID Node1 Node2 Diameter Type Setting MinorLoss 102 | 103 | [TAGS] 104 | 105 | [DEMANDS] 106 | ;Junction Demand Pattern Category 107 | 108 | [STATUS] 109 | ;ID Status/Setting 110 | 111 | [PATTERNS] 112 | ;ID Multipliers 113 | ;Demand Pattern 114 | 1 1.26 1.04 .97 .97 .89 1.19 115 | 1 1.28 .67 .67 1.34 2.46 .97 116 | 1 .92 .68 1.43 .61 .31 .78 117 | 1 .37 .67 1.26 1.56 1.19 1.26 118 | 1 .6 1.1 1.03 .73 .88 1.06 119 | 1 .99 1.72 1.12 1.34 1.12 .97 120 | 1 1.04 1.15 .91 .61 .68 .46 121 | 1 .51 .74 1.12 1.34 1.26 .97 122 | 1 .82 1.37 1.03 .81 .88 .81 123 | 1 .81 124 | ;Pump Station Outflow Pattern 125 | 2 .96 .96 .96 .96 .96 .96 126 | 2 .62 0 0 0 0 0 127 | 2 .8 1 1 1 1 .15 128 | 2 0 0 0 0 0 0 129 | 2 .55 .92 .92 .92 .92 .9 130 | 2 .9 .45 0 0 0 0 131 | 2 0 .7 1 1 1 1 132 | 2 .2 0 0 0 0 0 133 | 2 0 .74 .92 .92 .92 .92 134 | 2 .92 135 | ;Pump Station Fluoride Pattern 136 | 3 .98 1.02 1.05 .99 .64 .46 137 | 3 .35 .35 .35 .35 .35 .35 138 | 3 .17 .17 .13 .13 .13 .15 139 | 3 .15 .15 .15 .15 .15 .15 140 | 3 .15 .12 .1 .08 .11 .09 141 | 3 .09 .08 .08 .08 .08 .08 142 | 3 .08 .09 .07 .07 .09 .09 143 | 3 .09 .09 .09 .09 .09 .09 144 | 3 .09 .08 .35 .72 .82 .92 145 | 3 1 146 | 147 | [CURVES] 148 | ;ID X-Value Y-Value 149 | 150 | [CONTROLS] 151 | 152 | [RULES] 153 | 154 | [ENERGY] 155 | Global Efficiency 75 156 | Global Price 0.0 157 | Demand Charge 0.0 158 | 159 | [EMITTERS] 160 | ;Junction Coefficient 161 | 162 | [QUALITY] 163 | ;Node InitQual 164 | 1 1.0 165 | 2 1.0 166 | 3 1.0 167 | 4 1.0 168 | 5 1.0 169 | 6 1.0 170 | 7 1.0 171 | 8 1.0 172 | 9 1.0 173 | 10 1.0 174 | 11 1.0 175 | 12 1.0 176 | 13 1.0 177 | 14 1.0 178 | 15 1.0 179 | 16 1.0 180 | 17 1.0 181 | 18 1.0 182 | 19 1.0 183 | 20 1.0 184 | 21 1.0 185 | 22 1.0 186 | 23 1.0 187 | 24 1.0 188 | 25 1.0 189 | 27 1.0 190 | 28 1.0 191 | 29 1.0 192 | 30 1.0 193 | 31 1.0 194 | 32 1.0 195 | 33 1.0 196 | 34 1.0 197 | 35 1.0 198 | 36 1.0 199 | 26 1.0 200 | 201 | [SOURCES] 202 | ;Node Type Quality Pattern 203 | 1 CONCEN 1.0 3 204 | 205 | [REACTIONS] 206 | ;Type Pipe/Tank Coefficient 207 | 208 | 209 | [REACTIONS] 210 | Order Bulk 1 211 | Order Tank 1 212 | Order Wall 1 213 | Global Bulk 0.0 214 | Global Wall 0.0 215 | Limiting Potential 0.0 216 | Roughness Correlation 0.0 217 | 218 | [MIXING] 219 | ;Tank Model 220 | 221 | [TIMES] 222 | Duration 55:00 223 | Hydraulic Timestep 1:00 224 | Quality Timestep 0:05 225 | Pattern Timestep 1:00 226 | Pattern Start 0:00 227 | Report Timestep 1:00 228 | Report Start 0:00 229 | Start ClockTime 8 am 230 | Statistic None 231 | 232 | [REPORT] 233 | Status No 234 | Summary No 235 | Page 0 236 | 237 | [OPTIONS] 238 | Units GPM 239 | Headloss H-W 240 | Specific Gravity 1.0 241 | Viscosity 1.0 242 | Trials 40 243 | Accuracy 0.001 244 | CHECKFREQ 2 245 | MAXCHECK 10 246 | DAMPLIMIT 0 247 | Unbalanced Continue 10 248 | Pattern 1 249 | Demand Multiplier 1.0 250 | Emitter Exponent 0.5 251 | Quality Fluoride mg/L 252 | Diffusivity 1.0 253 | Tolerance 0.01 254 | 255 | [COORDINATES] 256 | ;Node X-Coord Y-Coord 257 | 1 21.00 4.00 258 | 2 19.00 20.00 259 | 3 11.00 21.00 260 | 4 14.00 28.00 261 | 5 19.00 25.00 262 | 6 28.00 23.00 263 | 7 36.00 39.00 264 | 8 38.00 30.00 265 | 9 36.00 42.00 266 | 10 37.00 23.00 267 | 11 37.00 49.00 268 | 12 39.00 60.00 269 | 13 38.00 64.00 270 | 14 38.00 66.00 271 | 15 37.00 69.00 272 | 16 27.00 65.00 273 | 17 27.00 69.00 274 | 18 23.00 68.00 275 | 19 21.00 59.00 276 | 20 45.00 68.00 277 | 21 51.00 62.00 278 | 22 54.00 69.00 279 | 23 35.00 74.00 280 | 24 37.00 71.00 281 | 25 35.00 76.00 282 | 27 39.00 87.00 283 | 28 49.00 85.00 284 | 29 42.00 86.00 285 | 30 47.00 80.00 286 | 31 37.00 80.00 287 | 32 23.00 64.00 288 | 33 56.00 73.00 289 | 34 56.00 77.00 290 | 35 43.00 81.00 291 | 36 53.00 87.00 292 | 26 33.00 76.00 293 | 294 | [VERTICES] 295 | ;Link X-Coord Y-Coord 296 | 297 | [LABELS] 298 | ;X-Coord Y-Coord Label & Anchor Node 299 | 24.00 7.00 "Pump" 300 | 24.00 4.00 "Station" 301 | 26.76 77.42 "Tank" 302 | 303 | [BACKDROP] 304 | DIMENSIONS 8.75 -0.15 58.25 91.15 305 | UNITS None 306 | FILE 307 | OFFSET 0.00 0.00 308 | 309 | [END] 310 | -------------------------------------------------------------------------------- /Licence.txt: -------------------------------------------------------------------------------- 1 | European Union Public Licence (EUPL) v1.1 2 | 3 | Copyright (c) 2007 The European Community 2007 4 | 5 | Preamble 6 | 7 | The attached "European Union Public Licence" ("EUPL") has been elaborated 8 | in the framework of IDABC, a European Community programme, with the aim to 9 | promote Interoperable Delivery of European eGovernment Services to public 10 | Administrations, Business and Citizens. IDABC continues and deepens the 11 | previous IDA ("Interchange of data between Administrations") programme. 12 | Software applications, such as CIRCA, a groupware for sharing documents 13 | within closed user groups, IPM, a tool helping administrations to close 14 | the gap between them and their stakeholders by providing a powerful and 15 | yet easy to use tool for direct consultation through the Internet, or 16 | eLink, a tool comprising the identification of remote services and the 17 | provision of reliable and secure messaging services over a network 18 | infrastructure, have been developed within the framework of the IDA or 19 | IDABC programmes. The European Community, on the basis of the contracts 20 | that permitted the development of such software, is owner of all 21 | Intellectual Property Rights and consequently of the source code and 22 | executables. 23 | 24 | Such IDA or IDABC developed tools are used by public administrations 25 | outside the European Institutions, under a licence delivered by the 26 | European Commission, which is the Institution acting on behalf of the 27 | European Community since the copyright for those tools belongs to the 28 | European Community. For some time, interest has increased in the 29 | publication of the software source code under a licence that would not 30 | limit access and modifications to the source code. 31 | 32 | The original EUPL Licence was established for such software, as 33 | corresponding to the IDABC objectives. The Licence is written in general 34 | terms and could therefore be used for derivative works, for other works 35 | and by other licensors. 36 | 37 | The utility of this Licence is to reinforce legal interoperability by 38 | adopting a common framework for pooling public sector software. 39 | This preamble is not a part of the EUPL Licence. 40 | 41 | Licence 42 | 43 | This European Union Public Licence (the "EUPL") applies to the Work or 44 | Software (as defined below) which is provided under the terms of this 45 | Licence. Any use of the Work, other than as authorised under this Licence 46 | is prohibited (to the extent such use is covered by a right of the 47 | copyright holder of the Work). 48 | 49 | The Original Work is provided under the terms of this Licence when the 50 | Licensor (as defined below) has placed the following notice immediately 51 | following the copyright notice for the Original Work: 52 | 53 | Licensed under the EUPL V.1.1 54 | 55 | or has expressed by any other mean his willingness to license under the 56 | EUPL. 57 | 58 | 1. Definitions 59 | In this Licence, the following terms have the following meaning: 60 | o The Licence: this Licence. 61 | o The Original Work or the Software: the software distributed 62 | and/or communicated by the Licensor under this Licence, 63 | available as Source Code and also as Executable Code as the 64 | case may be. 65 | o Derivative Works: the works or software that could be created 66 | by the Licensee, based upon the Original Work or modifications 67 | thereof. This Licence does not define the extent of 68 | modification or dependence on the Original Work required in 69 | order to classify a work as a Derivative Work; this extent is 70 | determined by copyright law applicable in the country 71 | mentioned in Article 15. 72 | o The Work: the Original Work and/or its Derivative Works. 73 | o The Source Code: the human-readable form of the Work which is 74 | the most convenient for people to study and modify. 75 | o The Executable Code: any code which has generally been 76 | compiled and which is meant to be interpreted by a computer as 77 | a program. 78 | o The Licensor: the natural or legal person that distributes 79 | and/or communicates the Work under the Licence. 80 | o Contributor(s): any natural or legal person who modifies the 81 | Work under the Licence, or otherwise contributes to the 82 | creation of a Derivative Work. 83 | o The Licensee or "You": any natural or legal person who makes 84 | any usage of the Software under the terms of the Licence. 85 | o Distribution and/or Communication: any act of selling, giving, 86 | lending, renting, distributing, communicating, transmitting, 87 | or otherwise making available, on-line or off-line, copies of 88 | the Work or providing access to its essential functionalities 89 | at the disposal of any other natural or legal person. 90 | 91 | 2. Scope of the rights granted by the Licence 92 | The Licensor hereby grants You a world-wide, royalty-free, non- 93 | exclusive, sub-licensable licence to do the following, for the 94 | duration of copyright vested in the Original Work: 95 | o use the Work in any circumstance and for all usage, 96 | o reproduce the Work, 97 | o modify the Original Work, and make Derivative Works based upon 98 | the Work 99 | o communicate to the public, including the right to make 100 | available or display the Work or copies thereof to the public 101 | and perform publicly, as the case may be, the Work, 102 | o distribute the Work or copies thereof, 103 | o lend and rent the Work or copies thereof, 104 | o sub-license rights in the Work or copies thereof. 105 | Those rights can be exercised on any media, supports and formats, 106 | whether now known or later invented, as far as the applicable law 107 | permits so. 108 | In the countries where moral rights apply, the Licensor waives his 109 | right to exercise his moral right to the extent allowed by law in 110 | order to make effective the licence of the economic rights here 111 | above listed. 112 | The Licensor grants to the Licensee royalty-free, non exclusive 113 | usage rights to any patents held by the Licensor, to the extent 114 | necessary to make use of the rights granted on the Work under this 115 | Licence. 116 | 117 | 3. Communication of the Source Code 118 | The Licensor may provide the Work either in its Source Code form, or 119 | as Executable Code. If the Work is provided as Executable Code, the 120 | Licensor provides in addition a machine-readable copy of the Source 121 | Code of the Work along with each copy of the Work that the Licensor 122 | distributes or indicates, in a notice following the copyright notice 123 | attached to the Work, a repository where the Source Code is easily 124 | and freely accessible for as long as the Licensor continues to 125 | distribute and/or communicate the Work. 126 | 127 | 4. Limitations on copyright 128 | Nothing in this Licence is intended to deprive the Licensee of the 129 | benefits from any exception or limitation to the exclusive rights of 130 | the rights owners in the Original Work or Software, of the 131 | exhaustion of those rights or of other applicable limitations 132 | thereto. 133 | 134 | 5. Obligations of the Licensee 135 | The grant of the rights mentioned above is subject to some 136 | restrictions and obligations imposed on the Licensee. Those 137 | obligations are the following: 138 | o Attribution right: the Licensee shall keep intact all 139 | copyright, patent or trademarks notices and all notices that 140 | refer to the Licence and to the disclaimer of warranties. The 141 | Licensee must include a copy of such notices and a copy of the 142 | Licence with every copy of the Work he/she distributes and/or 143 | communicates. The Licensee must cause any Derivative Work to 144 | carry prominent notices stating that the Work has been 145 | modified and the date of modification. 146 | o Copyleft clause: If the Licensee distributes and/or 147 | communicates copies of the Original Works or Derivative Works 148 | based upon the Original Work, this Distribution and/or 149 | Communication will be done under the terms of this Licence or 150 | of a later version of this Licence unless the Original Work is 151 | expressly distributed only under this version of the Licence. 152 | The Licensee (becoming Licensor) cannot offer or impose any 153 | additional terms or conditions on the Work or Derivative Work 154 | that alter or restrict the terms of the Licence. 155 | o Compatibility clause: If the Licensee Distributes and/or 156 | Communicates Derivative Works or copies thereof based upon 157 | both the Original Work and another work licensed under a 158 | Compatible Licence, this Distribution and/or Communication can 159 | be done under the terms of this Compatible Licence. For the 160 | sake of this clause, "Compatible Licence" refers to the 161 | licences listed in the appendix attached to this Licence. 162 | Should the Licensee's obligations under the Compatible Licence 163 | conflict with his/her obligations under this Licence, the 164 | obligations of the Compatible Licence shall prevail. 165 | o Provision of Source Code: When distributing and/or 166 | communicating copies of the Work, the Licensee will provide a 167 | machine-readable copy of the Source Code or indicate a 168 | repository where this Source will be easily and freely 169 | available for as long as the Licensee continues to distribute 170 | and/or communicate the Work. 171 | o Legal Protection: This Licence does not grant permission to 172 | use the trade names, trademarks, service marks, or names of 173 | the Licensor, except as required for reasonable and customary 174 | use in describing the origin of the Work and reproducing the 175 | content of the copyright notice. 176 | 177 | 6. Chain of Authorship 178 | The original Licensor warrants that the copyright in the Original 179 | Work granted hereunder is owned by him/her or licensed to him/her 180 | and that he/she has the power and authority to grant the Licence. 181 | Each Contributor warrants that the copyright in the modifications 182 | he/she brings to the Work are owned by him/her or licensed to him/ 183 | her and that he/she has the power and authority to grant the 184 | Licence. 185 | Each time You accept the Licence, the original Licensor and 186 | subsequent Contributors grant You a licence to their contributions 187 | to the Work, under the terms of this Licence. 188 | 189 | 7. Disclaimer of Warranty 190 | The Work is a work in progress, which is continuously improved by 191 | numerous contributors. It is not a finished work and may therefore 192 | contain defects or "bugs" inherent to this type of software 193 | development. 194 | For the above reason, the Work is provided under the Licence on an 195 | "as is" basis and without warranties of any kind concerning the 196 | Work, including without limitation merchantability, fitness for a 197 | particular purpose, absence of defects or errors, accuracy, non- 198 | infringement of intellectual property rights other than copyright as 199 | stated in Article 6 of this Licence. 200 | This disclaimer of warranty is an essential part of the Licence and 201 | a condition for the grant of any rights to the Work. 202 | 203 | 8. Disclaimer of Liability 204 | Except in the cases of wilful misconduct or damages directly caused 205 | to natural persons, the Licensor will in no event be liable for any 206 | direct or indirect, material or moral, damages of any kind, arising 207 | out of the Licence or of the use of the Work, including without 208 | limitation, damages for loss of goodwill, work stoppage, computer 209 | failure or malfunction, loss of data or any commercial damage, even 210 | if the Licensor has been advised of the possibility of such damage. 211 | However, the Licensor will be liable under statutory product 212 | liability laws as far such laws apply to the Work. 213 | 214 | 9. Additional agreements 215 | While distributing the Original Work or Derivative Works, You may 216 | choose to conclude an additional agreement to offer, and charge a 217 | fee for, acceptance of support, warranty, indemnity, or other 218 | liability obligations and/or services consistent with this Licence. 219 | However, in accepting such obligations, You may act only on your own 220 | behalf and on your sole responsibility, not on behalf of the 221 | original Licensor or any other Contributor, and only if You agree to 222 | indemnify, defend, and hold each Contributor harmless for any 223 | liability incurred by, or claims asserted against such Contributor 224 | by the fact You have accepted any such warranty or additional 225 | liability. 226 | 227 | 10. Acceptance of the Licence 228 | The provisions of this Licence can be accepted by clicking on an 229 | icon "I agree" placed under the bottom of a window displaying the 230 | text of this Licence or by affirming consent in any other similar 231 | way, in accordance with the rules of applicable law. Clicking on 232 | that icon indicates your clear and irrevocable acceptance of this 233 | Licence and all of its terms and conditions. 234 | Similarly, you irrevocably accept this Licence and all of its terms 235 | and conditions by exercising any rights granted to You by Article 2 236 | of this Licence, such as the use of the Work, the creation by You of 237 | a Derivative Work or the Distribution and/or Communication by You of 238 | the Work or copies thereof. 239 | 240 | 11. Information to the public 241 | In case of any Distribution and/or Communication of the Work by 242 | means of electronic communication by You (for example, by offering 243 | to download the Work from a remote location) the distribution 244 | channel or media (for example, a website) must at least provide to 245 | the public the information requested by the applicable law regarding 246 | the Licensor, the Licence and the way it may be accessible, 247 | concluded, stored and reproduced by the Licensee. 248 | 249 | 12. Termination of the Licence 250 | The Licence and the rights granted hereunder will terminate 251 | automatically upon any breach by the Licensee of the terms of the 252 | Licence. 253 | Such a termination will not terminate the licences of any person who 254 | has received the Work from the Licensee under the Licence, provided 255 | such persons remain in full compliance with the Licence. 256 | 257 | 13. Miscellaneous 258 | Without prejudice of Article 9 above, the Licence represents the 259 | complete agreement between the Parties as to the Work licensed 260 | hereunder. 261 | If any provision of the Licence is invalid or unenforceable under 262 | applicable law, this will not affect the validity or enforceability 263 | of the Licence as a whole. Such provision will be construed and/or 264 | reformed so as necessary to make it valid and enforceable. 265 | The European Commission may publish other linguistic versions and/or 266 | new versions of this Licence, so far this is required and 267 | reasonable, without reducing the scope of the rights granted by the 268 | Licence. New versions of the Licence will be published with a unique 269 | version number. 270 | All linguistic versions of this Licence, approved by the European 271 | Commission, have identical value. Parties can take advantage of the 272 | linguistic version of their choice. 273 | 274 | 14. Jurisdiction 275 | Any litigation resulting from the interpretation of this License, 276 | arising between the European Commission, as a Licensor, and any 277 | Licensee, will be subject to the jurisdiction of the Court of 278 | Justice of the European Communities, as laid down in article 238 of 279 | the Treaty establishing the European Community. 280 | Any litigation arising between Parties, other than the European 281 | Commission, and resulting from the interpretation of this License, 282 | will be subject to the exclusive jurisdiction of the competent court 283 | where the Licensor resides or conducts its primary business. 284 | 285 | 15. Applicable Law 286 | This Licence shall be governed by the law of the European Union 287 | country where the Licensor resides or has his registered office. 288 | This licence shall be governed by the Belgian law if: 289 | o a litigation arises between the European Commission, as a 290 | Licensor, and any Licensee; 291 | o the Licensor, other than the European Commission, has no 292 | residence or registered office inside a European Union 293 | country. 294 | 295 | Appendix 296 | 297 | "Compatible Licences" according to article 5 EUPL are: 298 | * General Public License (GPL) v. 2 299 | * Open Software License (OSL) v. 2.1, v. 3.0 300 | * Common Public License v. 1.0 301 | * Eclipse Public License v. 1.0 302 | * Cecill v. 2.0 --------------------------------------------------------------------------------