rtaormina / epanetCPA

epanetCPA is a MATLAB® toolbox for assessing the impacts of cyber-physical attacks on water distribution systems
23 stars 17 forks source link

Generated .inpx File Cannot Be Used #7

Closed seanotoole03 closed 3 years ago

seanotoole03 commented 4 years ago

While attempting to create a customized model for attack simulation, I've imported a BaseModel.inp file to use in tailoring attacks to a very simple network. However, attempting to run any scenario against the input model results in the following error messages from the Matlab Command Window: ` Error using EpanetHelper.epanetloadfile (line 112) Could not open network 'C:\Users\user\Documents\Research\EPANet\epanetCPA\BaseModel.inpx'. Returned empty array.

Error in EpanetCPAMap/initializeMap (line 189) EpanetHelper.epanetloadfile(self.modifiedFilePath);

Error in EpanetCPAMap (line 54) self = self.initializeMap();

Error in EpanetCPA (line 61) theMap = EpanetCPAMap(inpFile, self.cybernodes, self.cyberlinks, self.cyberoptions, PDA_ENABLED);

Error in main_baseModel (line 19) simul = EpanetCPA(inpFilePath, [scenarioFolder, noAttackCpaFile]); % `

I've compared and rewritten my model in order to match the format of your example minitown_map.inp and ctown_map.inp as closely as possible, and am even able to open and study the generated BaseModel.inpx file in EPANet2.0. However, this above error is returned every time, and the error code returned (Input Error 200) by the ENopen function simply provides the feedback "Input Error 200: one or more errors in input file". Clearly the error is not one significant enough to prevent the file from being opened and run in EPANet2.0, but it is nevertheless preventing the attack simulation from running. I have performed no modifications to the naturally generated .inpx file, and so am left stumped as to how to fix this and proceed.

User Basic Configurations: Windows 10 (64bit) Matlab R2020a (most recent update) EPANet 2.0 (with dev toolkit 2.2)

If more information is needed to assist in determining whether the issue lies in my own system or in the epanetCPA file generation, I am happy to provide whatever I can. Please find both BaseModel.inp and BaseModel.inpx attached for review and testing.

BaseModel.zip

seanotoole03 commented 3 years ago

Long-overdue follow-on: I was able to identify the issue, and tailor the code in the toolbox around it. epanetCPA makes the assumption that all tanks are same-inlet-as-outlet, which is not the case for my network. Instead, the tanks are set up as though in a water treatment and pumping station, with separate inlet and outlet pipes for each tank. The issue arises when the toolkit attempts to create duplicate pipes and junctions for the tanks, as it generates identically-named junctions, pipes, and tanks. I've compensated for this with checks for duplicates in the code generating those, and instead connected both inlet and outlet pipes to the same overflow tank. While fairly rudimentary, it has been sufficient for getting the program to run when needed over the past few months. Can share those edits for merging if desired. Either way, the issue here is identified and resolved.