-
Notifications
You must be signed in to change notification settings - Fork 0
/
OptParser.h
884 lines (743 loc) · 26.4 KB
/
OptParser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
/*
* File: OptParser.h
* Author: jnewman
*
* Created on June 7, 2010, 6:21 PM
*/
#ifndef _OPTPARSER_H
#define _OPTPARSER_H
#include <vector>
#include <map>
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/fusion/include/std_pair.hpp>
#include <boost/filesystem.hpp>
//#include <bits/stl_algobase.h>
/**
* qi provides parsing functionality and is part of boost spirit
*/
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
namespace phoenix = boost::phoenix;
/**
* We will be parsing strings. We define a string iterator as Str_it
*/
typedef std::string::const_iterator Str_it; /**< A string const iterator - used for reading the input of the OptFile */
/**
* @brief this defines what the parser should skip in the optFile
* @details think of these are grammers - they define the rules of
* how the input file should be formatted. This one defines how
* comments should be formatted - because these are skipped over, as well as white space
* @see Boost spirit documentation
*/
struct Skipper : qi::grammar< Str_it >
{
Skipper();
qi::rule< Str_it > skip_it; /**< Rule that does the work. passes over commetns and whitespace in the file */
qi::rule<Str_it> comment; /**< Rule that detects comments in the file.*/
char comment_char; /**< Define what the comment character is. I.e. we follow the Epanet inp file tradition of ';' */
};
/**
* @brief a custom skipper that skips over blanks but does not skip over end of lines
* @details think of these as grammers - they define the rules of
* how the input file should be formatted. This one defines how
* comments should be formatted - because these are skipped over, as well as white space, but not end of lines
* @see Boost spirit documentation
*/
struct No_eol_skip : qi::grammar< Str_it > /**< Rule that does the work. passes over commetns and whitespace in the file */
{
No_eol_skip();
qi::rule< Str_it > skip_it; /**< Rule that does the work. passes over commetns and whitespace in the file */
qi::rule<Str_it> comment; /**< Rule that detects comments in the file.*/
char comment_char; /**< Define what the comment character is. I.e. we follow the Epanet inp file tradition of ';' */
};
class IFException : public std::runtime_error
{
public:
IFException();
IFException(std::string what);
};
class ObjectiveInputError : public IFException
{
public:
ObjectiveInputError();
ObjectiveInputError(std::string what);
};
//----------------------------------------------------------------------
// DATA ON AVAILABLE PIPES
//----------------------------------------------------------------------
struct PipeDataProperties {
//std::string id;
std::string description;
double roughnessHeight;
double diameter;
double cost;
double repairCost;
double embodiedEnergy;
double repairEE;
double ghg;
double topCover;
double sideCover;
double bottomCover;
};
struct TreatmentProperties {
std::string description;
double waterload;
double capitalcost;
double annualOpCost;
};
struct PumpProperties {
std::string description;
double head;
//double capitalcost;
double efficiency;
};
struct VSPStationDetails {
std::string description;
std::string resID;
std::string prvID;
std::string linkID;
std::string interNode;
std::string outletNode;
std::string determineAvgBy;
int timestep;
std::string NodeGroupID;
};
struct TankProperties {
double init_storage;
double surface_area;
double height;
double peakAllotmentDemand;
double peakSupply;
double peakExternalSupplyPerAllot;
double avgSupply;
double avgAllotmentDemand;
double avgExternalSupplyPerAllot;
double netExternalSupplyPerAllot;
double cost;
double embodied_energy;
double other_cost;
double other_EE;
int numAllots;
};
struct TankChoices {
std::string potDemandPatternID;
std::string potNodeGroup;
std::string rcylDemandPatternID;
std::string rcylNodeGroup;
std::vector<std::string> tankOptionIDs;
};
struct DistSysPipeGroups {
int numAllotments;
std::vector<std::string> pipeGroupIDs;
};
BOOST_FUSION_ADAPT_STRUCT( PipeDataProperties,
//(std::string, id)
(std::string, description
)//
(double, roughnessHeight)//
(double, diameter)//
(double, cost)//
(double, repairCost)//
(double, embodiedEnergy)//
(double, repairEE)//
(double, ghg)//
(double, topCover)//
(double, sideCover)//
(double, bottomCover)//
)
BOOST_FUSION_ADAPT_STRUCT( TreatmentProperties,
(std::string, description
) //
(double, waterload)//
(double, capitalcost)//
(double, annualOpCost)//
)
BOOST_FUSION_ADAPT_STRUCT( PumpProperties, //
(std::string, description
)//
(double, head)//
//(double, capitalcost)
(double, efficiency)//
)
BOOST_FUSION_ADAPT_STRUCT( VSPStationDetails, //
(std::string, description
)//
(std::string, resID)//
(std::string, prvID)//
(std::string, linkID)//
(std::string, interNode)//
(std::string, outletNode)//
(std::string, determineAvgBy)//
(int, timestep)//
(std::string, NodeGroupID)//
)
BOOST_FUSION_ADAPT_STRUCT( TankProperties, //
(
double, init_storage)//
(double, surface_area)//
(double, height)//
(double, peakAllotmentDemand)//
(double, peakSupply)//
(double, peakExternalSupplyPerAllot)//
(double, avgSupply)//
(double, avgAllotmentDemand)//
(double, avgExternalSupplyPerAllot)//
(double, netExternalSupplyPerAllot)//
(double, cost)//
(double, embodied_energy)//
(double, other_cost)//
(double, other_EE)//
(int, numAllots)//
)
BOOST_FUSION_ADAPT_STRUCT( TankChoices, //
(std::string, potDemandPatternID
)//
(std::string, potNodeGroup)//
(std::string, rcylDemandPatternID)//
(std::string, rcylNodeGroup)//
(std::vector<std::string>, tankOptionIDs)//
)
BOOST_FUSION_ADAPT_STRUCT( DistSysPipeGroups, //
(
int, numAllotments)//
(std::vector<std::string>, pipeGroupIDs)//
)
typedef std::string::const_iterator Str_it; /**< A string const iterator - used for reading the input of the OptFile */
typedef std::map<std::string, PipeDataProperties> PipeDataType;
struct PipeData {
PipeData(PipeDataType::iterator &it) :
id(it->first), details(it->second) {
}
const std::string &id;
PipeDataProperties &details;
};
typedef std::map<std::string, TreatmentProperties> TreatmentsType;
struct TreatmentData {
TreatmentData(TreatmentsType::iterator &it) :
id(it->first), details(it->second) {
}
const std::string &id;
TreatmentProperties &details;
};
typedef std::vector<std::pair<std::string, PumpProperties> > PumpingOptionsType;
struct PumpOptionsData {
PumpOptionsData(PumpingOptionsType::iterator &it) :
id(it->first), details(it->second) {
}
const std::string &id;
PumpProperties &details;
};
typedef std::map<std::string, VSPStationDetails> VSPType;
struct vspData {
vspData(VSPType::iterator &it) :
id(it->first), details(it->second) {
}
const std::string &id;
VSPStationDetails &details;
};
typedef std::map<std::string, TankProperties> TanksType;
struct TankData {
TankData(TanksType::iterator &it) :
id(it->first), details(it->second) {
}
const std::string &id;
TankProperties &details;
};
//----------------------------------------------------------------------
// EPANET PIPES ARE GROUPED; EACH GROUP HAS A PIPE DIAMETER USED FOR ALL PIPES IN THE GROUP
// ONE DECISION PER GROUP - WHAT SHOULD THE DIAMETER BE?
//----------------------------------------------------------------------
typedef std::map<std::string, std::vector<std::string> > LinkGroupsType;
struct LinkGroups {
typedef std::vector<std::string> PipeIdVec;
typedef std::vector<std::string>::iterator iterator;
LinkGroups(LinkGroupsType::iterator &it) :
groupId(it->first), epanetLinkIds(it->second) {
}
const std::string &groupId;
PipeIdVec &epanetLinkIds;
};
typedef std::map<std::string, std::pair<double, double> > NodeConstraintsT;
struct Pressures {
Pressures(NodeConstraintsT::iterator &it) :
id(it->first), minPressure(it->second.first), maxPressure(
it->second.second) {
}
const std::string &id;
double &minPressure;
double &maxPressure;
};
struct Heads {
Heads(NodeConstraintsT::iterator &it) :
id(it->first), minHead(it->second.first), maxHead(
it->second.second) {
}
const std::string &id;
double &minHead;
double &maxHead;
};
typedef std::map<std::string, double> VelocityConstraintsT;
struct Velocities {
Velocities(VelocityConstraintsT::iterator &it) :
id(it->first), maxVelocity(it->second) {
}
const std::string &id;
double &maxVelocity;
};
//----------------------------------------------------------------------
// Each Group has a list of pipes; one of these pipes must be chosen for the groups
// One pipe per group;
//----------------------------------------------------------------------
typedef std::map<std::string, std::vector<std::string> > PipeAvailOptionsType;
struct PipeAvailOptions {
typedef std::vector<std::string> PipeDataIdVec;
typedef std::vector<std::string>::iterator iterator;
PipeAvailOptions(PipeAvailOptionsType::iterator &it) :
groupId(it->first), pipeDataIds(it->second) {
}
const std::string &groupId;
PipeDataIdVec &pipeDataIds;
};
//Each storage has a list of avialble tanks; on eof these must be chosen for the groups
typedef std::map<std::string, TankChoices> TankAvailableOptionsType;
struct TankAvailableOptions {
TankAvailableOptions(TankAvailableOptionsType::iterator &it) :
storageId(it->first), details(it->second) {
}
const std::string &storageId;
TankChoices &details;
};
typedef std::map<std::string, DistSysPipeGroups> DistSysPipeGroupsType;
struct DistSystems {
DistSystems(DistSysPipeGroupsType::iterator &it) :
distSysId(it->first), details(it->second) {
}
const std::string &distSysId;
DistSysPipeGroups &details;
};
typedef std::map<std::string, std::vector<std::string> > NodeGroupsType;
struct NodeGroups {
typedef std::vector<std::string> NodeIdVec;
typedef std::vector<std::string>::iterator iterator;
NodeGroups(NodeGroupsType::iterator &it) :
groupId(it->first), nodeIds(it->second) {
}
const std::string &groupId;
NodeIdVec &nodeIds;
};
typedef std::pair<int, double> TarifPair;
typedef std::map<int, double> TarifStructure;
enum ENVersion{OWA_EN2, OWA_EN3, Ibanev_EN2};
struct OptData {
OptData();
PipeDataType pipe_data_map;
LinkGroupsType link_groups_data;
NodeGroupsType node_groups_data;
PipeAvailOptionsType pipe_availOpt_data;
TankAvailableOptionsType tank_availOpt_data;
VSPType vsp_data;
NodeConstraintsT pressure_constraints;
VelocityConstraintsT velocity_constraints;
NodeConstraintsT head_constraints;
double PressurePenaltyCost;
double PressurePenaltyEE;
double PressurePenaltyWtr;
double HeadPenaltyCost;
double HeadPenaltyEE;
double HeadPenaltyWtr;
double VelocityPenaltyCost;
double VelocityPenaltyEE;
double VelocityPenaltyWtr;
double TreatmentPenaltyCost;
double TreatmentPenaltyEE;
double TreatmentPenaltyWtr;
double TrenchingCost;
double FittingsCost;
double FittingsEE;
double GreywaterSysCost;
double HouseConnectionsCost;
double GreywaterEE;
std::string epanet_dylib_loc;
std::string iuwmod_nodeext_loc;
std::string iuwmod_linkext_loc;
double trenchEE;
double drateEE;
double drateCost;
double netWaterDemand;
double greywaterContrib;
double energyCost;
int planHorizon;
int numAllotments;
TreatmentsType treatments_data;
PumpingOptionsType pump_options_data;
// Those relating to pumping stations:
double peakPumpEfficiency; //NOT APPARENTLY USED
double avgPumpEfficiency;
int pumpElectricsLife;
int pumpMechanicsLife;
int pumpCivilLife;
int treatmentLife;
TanksType storage_tank_data;
DistSysPipeGroupsType dist_groups_data;
std::string pot_topup_node_name;
std::string en_pat_id;
double treatementLogReduction;
TarifStructure waterTariffs;
double externalWaterEnergy;
double externalTreatmentCost;
double externalTreatmentEnergy;
bool isDistSystem;
bool isCollSystem;
bool isWtrBalSystem;
bool isOptPipes;
bool isOptVSP;
bool isOptTanks;
bool isCostObj;
bool isNetworkResiliencyObj;
bool isEnergyObj;
bool isWtrObj;
bool isPressureConstraint;
bool isHeadConstraint;
bool isVelocityConstraint;
bool allTankChoicesTheSame;
std::string epanetFile;
std::string iuwmodFile;
double dailyPumpOpHours;
double dayPeak_hourPeakRatio;
ENVersion en_lib_version;
std::vector<std::string> *
getOrNewLinkGroup(const std::string &name);
std::vector<std::string> *
getOrNewPipeOptions(const std::string &groupName);
void
setOrNewPressureConstraint(const std::string &name,
const double &minP, const double &maxP);
void
setOrNewHeadConstraint(const std::string &name,
const double &minP, const double &maxP);
void
setOrNewVelocityConstraint(const std::string &name,
const double &maxV);
};
typedef boost::shared_ptr <OptData> OptData_SPtr;
/**
* @brief Defines the grammer (format) of the data to be read into the program, and holds this data also.
* @details. This is more then a grammer (format) specification of the input file). It actually stores
* the data that it reads in
*/
struct OptFileParser : qi::grammar<Str_it, Skipper> {
public:
OptFileParser();
OptFileParser(OptData_SPtr _optData);
//This is the highest-level rule.
qi::rule <Str_it, Skipper> start;
qi::rule <Str_it, Skipper> specification_rule;
qi::rule <Str_it, Skipper> specification_header;
qi::rule <Str_it, Skipper> systemRule;
qi::rule <Str_it, Skipper> OptimiseRule;
qi::rule <Str_it, Skipper> ObjectivesRule;
qi::rule <Str_it, Skipper> ConstraintsRule;
qi::rule<Str_it, bool(), Skipper> isDistSystem_rule;
qi::rule<Str_it, bool(), Skipper> isCollSystem_rule;
qi::rule<Str_it, bool(), Skipper> isWtrBalSystem_rule;
qi::rule<Str_it, bool(), Skipper> isOptPipes_rule;
qi::rule<Str_it, bool(), Skipper> isOptVSP_rule;
qi::rule<Str_it, bool(), Skipper> isOptTanks_rule;
qi::rule<Str_it, bool(), Skipper> allTanksSameSize_rule;
qi::rule<Str_it, bool(), Skipper> allowVariableSize_rule;
qi::rule<Str_it, bool(), Skipper> isCostObj_rule;
qi::rule<Str_it, bool(), Skipper> isNetworkResiliency_rule;
qi::rule<Str_it, bool(), Skipper> isEnergyObj_rule;
qi::rule<Str_it, bool
(), Skipper> isWtrObj_rule;
qi::rule<Str_it, bool
(), Skipper> isPressureConstraint_rule;
qi::rule<Str_it, bool
(), Skipper> isHeadConstraint_rule;
qi::rule<Str_it, bool
(), Skipper> isVelocityConstraint_rule;
qi::rule<Str_it, std::string
(), Skipper> en_inp_rule;
qi::rule<Str_it, std::string
(), Skipper> iuwmod_inp_rule;
//Generic rules, used a lot.
qi::rule<Str_it, std::string
(), Skipper> white_seperated_string;
qi::rule<Str_it, std::string
(), Skipper> white_seperated_string_then_eol;
qi::rule<Str_it, std::vector<std::string>
(), Skipper> list_white_seperated_string;
qi::rule<Str_it, double
(), Skipper> double_then_end_of_line;
qi::rule<Str_it, int
(), Skipper> int_then_end_of_line;
qi::rule <Str_it, Skipper> headers;
//Rules that define the Pipe data section of the input file
qi::rule <Str_it, Skipper> pipe_data_header;
qi::rule<Str_it, std::string
(), Skipper> pipe_datum_id;
qi::rule<Str_it, std::string
(), Skipper> pipe_data_description;
qi::rule<Str_it, PipeDataProperties
(), Skipper> pipe_datum_info;
qi::rule<Str_it, std::pair<std::string, PipeDataProperties>
(), Skipper> pipe_datum;
qi::rule<Str_it, PipeDataType
(), Skipper> pipe_data;
//rules that define the treatments section of the input file
qi::rule <Str_it, Skipper> treatments_header;
qi::rule<Str_it, std::string
(), Skipper> treatment_id;
qi::rule<Str_it, std::string
(), Skipper> treatment_description;
qi::rule<Str_it, double
(), Skipper> capacity;
qi::rule<Str_it, double
(), Skipper> capital_cost;
qi::rule<Str_it, double
(), Skipper> operate_cost;
qi::rule<Str_it, TreatmentProperties
(), Skipper> treatment_info;
qi::rule<Str_it, std::pair<std::string, TreatmentProperties>
(), Skipper> treatment_datum;
qi::rule<Str_it, TreatmentsType
(), Skipper> treatment_data;
//rules that define the tank properties part of the input file
qi::rule <Str_it, Skipper> tanks_header;
qi::rule<Str_it, std::string
(), Skipper> tank_id;
// qi::rule< Str_it, TankProperties
// (), Skipper > tank_info1;
// qi::rule< Str_it, TankProperties
// (), Skipper > tank_info2;
qi::rule<Str_it, TankProperties
(), Skipper> tank_info3;
qi::rule<Str_it, std::pair<std::string, TankProperties>
(), Skipper> tank_datum;
qi::rule<Str_it, TanksType
(), Skipper> tank_data;
//rules that define the pumping section of the input file
qi::rule <Str_it, Skipper> pumping_header;
qi::rule<Str_it, std::string
(), Skipper> pump_id;
qi::rule<Str_it, std::string
(), Skipper> pump_description;
qi::rule<Str_it, double
(), Skipper> head;
qi::rule<Str_it, double
(), Skipper> efficiency;
qi::rule<Str_it, PumpProperties
(), Skipper> pump_info;
qi::rule<Str_it, std::pair<std::string, PumpProperties>
(), Skipper> pump_datum;
qi::rule<Str_it, PumpingOptionsType
(), Skipper> pump_data;
//Rules that define the pipe group section of the input file
qi::rule <Str_it, Skipper> pipe_group_header;
qi::rule<Str_it, std::string
(), Skipper> pipe_group_id;
qi::rule<Str_it, std::vector<std::string>
(), Skipper> epanet_pipe_ids;
qi::rule<Str_it,
std::pair<std::string, std::vector<std::string> >
(), Skipper> pipe_group;
qi::rule<Str_it, LinkGroupsType
(), Skipper> pipe_groups;
//Rules that define the pipe group section of the input file
qi::rule <Str_it, Skipper> node_group_header;
qi::rule<Str_it, std::string
(), Skipper> node_group_id;
qi::rule<Str_it, std::vector<std::string>
(), Skipper> epanet_node_ids;
qi::rule<Str_it,
std::pair<std::string, std::vector<std::string> >
(), Skipper> node_group;
qi::rule<Str_it, NodeGroupsType
(), Skipper> node_groups;
// rules that define the pipe choices section of the input file
qi::rule <Str_it, Skipper> pipe_choices_header;
qi::rule<Str_it, std::vector<std::string>
(), Skipper> pipe_data_ids;
qi::rule<Str_it,
std::pair<std::string, std::vector<std::string> >
(), Skipper> pipe_choice;
qi::rule<Str_it, PipeAvailOptionsType
(), Skipper> pipe_choices;
// rules that define the tank choices section of the input file
qi::rule <Str_it, Skipper> tank_choices_header;
qi::rule<Str_it, std::vector<std::string>
(), Skipper> tank_data_ids;
qi::rule<Str_it, std::string
(), Skipper> potDemandPatternID_rule;
qi::rule<Str_it, std::string
(), Skipper> potNodeGroup_rule;
qi::rule<Str_it, std::string
(), Skipper> rcylDemandPatternID_rule;
qi::rule<Str_it, std::string
(), Skipper> rcylNodeGroup_rule;
qi::rule<Str_it, TankChoices
(), Skipper> tank_choice_info;
qi::rule<Str_it, std::pair<std::string, TankChoices>
(), Skipper> tank_choice_datum;
qi::rule<Str_it, PipeAvailOptionsType
(), Skipper> tank_choices;
//rules that define the pipe groups within each dist. system
qi::rule <Str_it, Skipper> dist_groups_header;
qi::rule<Str_it, std::string
(), Skipper> dist_group_ID_rule;
qi::rule<Str_it, std::vector<std::string>
(), Skipper> groups_in_sys_ids_rule;
qi::rule<Str_it, DistSysPipeGroups
(), Skipper> dist_groups_info;
qi::rule<Str_it, std::pair<std::string, DistSysPipeGroups>
(), Skipper> dist_groups_datum;
// qi::rule< Str_it, DistSysPipeGroupsType
// (), Skipper > dist_groups;
qi::rule <Str_it, Skipper> dist_groups;
//Rules that define the penalities part of the input file
qi::rule <Str_it, Skipper> penalties_header;
qi::rule <Str_it, Skipper> pressureConstraintPenalty_rule;
qi::rule <Str_it, Skipper> headConstraintPenalty_rule;
qi::rule <Str_it, Skipper> velocityConstraintPenalty_rule;
qi::rule <Str_it, Skipper> treatmentConstraintPenalty_rule;
qi::rule <Str_it, Skipper> penalties;
//Rules that define the variable speed pump part of the specificiation file
qi::rule <Str_it, Skipper> vsp_header;
qi::rule<Str_it, VSPStationDetails
(), Skipper> vsp_info1;
qi::rule<Str_it, VSPStationDetails
(), Skipper> vsp_info2;
qi::rule<Str_it, std::pair<std::string, VSPStationDetails>
(), Skipper> vsp_datum1;
qi::rule<Str_it, std::pair<std::string, VSPStationDetails>
(), Skipper> vsp_datum2;
qi::rule<Str_it, std::string
(), Skipper> vsp_avg_rule;
qi::rule<Str_it, std::string
(), Skipper> vsp_ts_rule;
qi::rule<Str_it, VSPType
(), Skipper> vsp_data_rule;
//rules that define the evaluation part of the input file.
qi::rule <Str_it, Skipper> evaluation_header;
qi::rule<Str_it, double
(), Skipper> trenchingCost_rule;
qi::rule<Str_it, double
(), Skipper> fittingsCost_rule;
qi::rule<Str_it, double
(), Skipper> fittingsEE_rule;
qi::rule<Str_it, double
(), Skipper> greywaterSysCost_rule;
qi::rule<Str_it, double
(), Skipper> houseConnectionsCost_rule;
qi::rule<Str_it, double
(), Skipper> greywaterEE_rule;
qi::rule <Str_it, Skipper> evaluation;
qi::rule<Str_it, Skipper> en_lib_rule;
qi::rule<Str_it, std::string
(), Skipper> en_lib_path_rule;
qi::rule<Str_it, std::string
(), Skipper> iuwm_nodeext_rule;
qi::rule<Str_it, std::string
(), Skipper> iuwm_linkext_rule;
qi::rule<Str_it, double
(), Skipper> trenchEE_rule;
qi::rule<Str_it, double
(), Skipper> discountEE_rule;
qi::rule<Str_it, double
(), Skipper> discountCost_rule;
qi::rule<Str_it, double
(), Skipper> netWaterDemand_rule;
qi::rule<Str_it, double
(), Skipper> greywaterContrib_rule;
qi::rule<Str_it, int
(), Skipper> numAllotments_rule;
qi::rule<Str_it, double
(), Skipper> energyCost_rule;
qi::rule<Str_it, int
(), Skipper> planPeriod_rule;
qi::rule<Str_it, double
(), Skipper> peakPumpEfficiency_rule;
qi::rule<Str_it, double
(), Skipper> avgPumpEfficiency_rule;
qi::rule<Str_it, int
(), Skipper> pumpElectricsLife_rule;
qi::rule<Str_it, int
(), Skipper> pumpMechanicsLife_rule;
qi::rule<Str_it, int
(), Skipper> pumpCivilLife_rule;
qi::rule<Str_it, int
(), Skipper> treatmentLife_rule;
qi::rule<Str_it, double
(), Skipper> dailyPumpOpHours_rule;
qi::rule<Str_it, double
(), Skipper> dayPeak_hourPeakRatio_rule;
qi::rule<Str_it, std::string
(), Skipper> iuwm_topupNde_rule;
qi::rule<Str_it, std::string
(), Skipper> en_pat_id_rule;
qi::rule<Str_it, double
(), Skipper> treatLogReduction_rule;
qi::rule <Str_it, Skipper> extWaterEnergyRule;
qi::rule <Str_it, Skipper> extTreatEnergyRule;
qi::rule <Str_it, Skipper> extTreatCostRule;
qi::rule<Str_it, TarifPair(), Skipper> tarifPairRule;
qi::rule <Str_it, Skipper> extWaterCostRule;
//rules that define the pressure constrain part of the input file
qi::rule <Str_it, Skipper> pressures_header;
qi::rule<Str_it, std::string
(), Skipper> node_id;
qi::rule<Str_it, double
(), Skipper> min_pressure;
qi::rule<Str_it, double
(), Skipper> max_pressure;
qi::rule<Str_it, std::pair<double, double>
(), Skipper> mm_pressure_constraint;
qi::rule<Str_it,
std::pair<std::string, std::pair<double, double> >
(), Skipper> pressure_constraint;
qi::rule<Str_it, NodeConstraintsT
(), Skipper> pressure_constraints_r;
//rules that define the heads constrain part of the input file
qi::rule <Str_it, Skipper> heads_header;
qi::rule<Str_it, double
(), Skipper> min_head;
qi::rule<Str_it, double
(), Skipper> max_head;
qi::rule<Str_it, std::pair<double, double>
(), Skipper> mm_head_constraint;
qi::rule<Str_it,
std::pair<std::string, std::pair<double, double> >
(), Skipper> head_constraint;
qi::rule<Str_it, NodeConstraintsT
(), Skipper> head_constraints_r;
//rules that define the velocities part of the input file
qi::rule <Str_it, Skipper> velocities_header;
qi::rule<Str_it, std::string
(), Skipper> pipe_id;
qi::rule<Str_it, double
(), Skipper> max_velocity;
qi::rule<Str_it, std::pair<std::string, double>
(), Skipper> velocity_constraint;
qi::rule<Str_it, VelocityConstraintsT
(), Skipper> velocity_constraints_r;
No_eol_skip customSkipper;
boost::shared_ptr <OptData> optData;
private:
void
init();
};
typedef boost::shared_ptr <OptFileParser> OptParser_SPtr;
std::ostream &
operator<<(std::ostream &os, const OptData &optdata);
void
printOptToFile(const OptData &optdata, std::string fileName);
void
printOptToFile_CStr(const OptData &optdata, const char *fileName);
//Function for getting the
OptData_SPtr
getObjectiveInput(boost::filesystem::path optFile);
#endif /* _OPTPARSER_H */