Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding constrained sensing capabilities to the SPSL post processor. Added a test_SPSL_constrained xml for testing. #2346

Open
wants to merge 57 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
5055f61
starting classification
Jimmy-INL Nov 5, 2023
32f6a5c
adding classification data
Jimmy-INL Nov 6, 2023
8a1b5d5
hard coding the labels for now till we decide on naming
Jimmy-INL Feb 20, 2024
66b4adf
adding the state variable and remove the hard coding
Jimmy-INL Feb 23, 2024
226b5a8
adding test and golded files
Jimmy-INL Feb 23, 2024
53c72e3
Adding modified SPSL with constraints
Jun 4, 2024
3c19e83
Adding test file for constraints SPSL
Jun 4, 2024
9c435e0
Merge branch 'SPSL_add_constraints' of https://github.com/niharika299…
Jul 29, 2024
a092359
Adding path the pysensors branch for constraints in dependencies and …
Jul 29, 2024
047fdf1
deleting trailing whitespaces in the file SparseSensing.py
niharika2999 Jul 30, 2024
357a16a
Removing git+ from dependencies as the library handler adds git+
niharika2999 Jul 30, 2024
bd72312
Fixing constrainedRegion being None error
niharika2999 Jul 30, 2024
4dbfa69
Changing variable name target to measuredState in the workshop SPSL test
niharika2999 Jul 30, 2024
4a71208
Fixing constrainedRegions Typo
niharika2999 Jul 30, 2024
5a55ae4
Fixing missing else statement for ConstrainedRegions
niharika2999 Jul 30, 2024
207b0cf
Fixing error by including _ConstrainedRegionsType= None
niharika2999 Aug 1, 2024
b59e4d0
Adding the test from workshop with target changed to measuredState
niharika2999 Aug 1, 2024
d2dc13b
Changing target to measuredState in the workshop inputs folder
niharika2999 Aug 1, 2024
a288140
Updating documentation for the sparse sensing postprocessor
niharika2999 Aug 2, 2024
fb43bec
Fixing \_n issues for max_n and exact_n in the documentation
niharika2999 Aug 2, 2024
26284ee
Adding \_ to the documentation inside xml node and removing the typo …
niharika2999 Aug 2, 2024
3f7b970
Changing xy_coords in the documentation
niharika2999 Aug 5, 2024
60517e5
Adding doc, changes to SparseSensing.py and tests for each shape
niharika2999 Aug 5, 2024
ef79d99
Fixing .csv to ./csv in the tests
niharika2999 Aug 5, 2024
a4a1159
Adding the folders that contain csv data in tests for the constraints
niharika2999 Aug 5, 2024
b6d4a9d
Changes to xml's
niharika2999 Aug 5, 2024
aa0a10a
Fixing xml and adding missed line test
niharika2999 Aug 5, 2024
b31c4fa
Changes to the SparseSensing postprocessor
niharika2999 Aug 6, 2024
44b71f7
Changes to the SparseSensing postprocessor
niharika2999 Aug 6, 2024
bf3d244
Trying to remove whitespace
niharika2999 Aug 6, 2024
d09da7e
Deleting trailing whitespace
niharika2999 Aug 6, 2024
dbb792d
Fixed Sparsesesning postprocessor
niharika2999 Aug 15, 2024
c6d40b4
Adding working SparseSensing
niharika2999 Aug 15, 2024
4618f3d
Almost finished SparseSensing.py and gold files for circle, ellipse a…
niharika2999 Aug 16, 2024
0377df7
Adding files for gold folder in tests
niharika2999 Aug 19, 2024
cfba5ed
Changing cloudpickle dependency from2.2 to 3.0
niharika2999 Aug 19, 2024
8155b90
adding circle, polygon, ellipse to gold in tests
Sep 16, 2024
c06a2bb
Merge branch 'devel' into SPSL_add_constraints
niharika2999 Sep 16, 2024
9eaf38b
Trying to fix errors for circle and ellipse constraints tests
Sep 16, 2024
254895a
Merge branch 'SPSL_add_constraints' of https://github.com/niharika299…
Sep 16, 2024
bf98b39
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
03428a5
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
4975ad8
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
7e12525
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
ad67ac2
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
995c889
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
f143170
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
d66eae9
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
21d686b
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
9e5835e
Changing working directory for the tests
Sep 17, 2024
0b1b272
Merge branch 'SPSL_add_constraints' of https://github.com/niharika299…
Sep 17, 2024
307dabe
Renaming folders for tests
Sep 17, 2024
6bcca52
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
a5b9be5
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
676fd20
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
99066b5
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
e3b6a09
Delete tests/framework/PostProcessors/SparseSensing/reconstructionCon…
niharika2999 Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Note all install methods after "main" take
<!-- <ete3 optional='True'/> -->
<statsforecast/>
<pywavelets optional='True'>1.2</pywavelets>
<python-sensors source="pip"/>
<python-sensors source="pip" repo='https://github.com/Jimmy-INL/pysensors.git@niharika2999-Ni_converting_functional-constraints_class'></python-sensors>
<numdifftools source="pip">0.9</numdifftools>
<fmpy optional='True'/>
<xmlschema source="pip"/>
Expand Down
92 changes: 85 additions & 7 deletions doc/user_manual/PostProcessors/SparseSensing.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ \subsubsection{SparseSensing}
\begin{itemize}
\item Manohar, Krithika, et al. ``Data-driven sparse sensor placement for reconstruction: Demonstrating the benefits of exploiting known patterns.'' IEEE Control Systems Magazine 38.3 (2018): 63-86 for more information about the PySensors approach to reconstruction problems and,
\item Brunton, Bingni W., et al. ``Sparse sensor placement optimization for classification.'' SIAM Journal on Applied Mathematics 76.5 (2016): 2099-2122 for classification and,
\item de Silva, Brian M., et al. ``PySensors: A Python package for sparse sensor placement.'' arXiv preprint arXiv:2102.13476 (2021) contains a full literature review along with examples and additional tips for using PySensors effectively.
\item de Silva, Brian M., et al. ``PySensors: A Python package for sparse sensor placement.'' arXiv preprint arXiv:2102.13476 (2021) contains a full literature review along with examples and additional tips for using PySensors effectively,
\item Karnik, Niharika, et al. ``Constrained Optimization of Sensor Placement for Nuclear Digital Twins.'' IEEE Sensors Journal Volume: 24 Issues: 9 (2024) for more details about constrained optimization of sensor placement,
\item Karnik, Niharika, et al. ``Leveraging Optimal Sparse Sensor Placement to Aggregate a Network of Digital Twins for Nuclear Subsystems.''Energies, 17(13), 3355. (2024) for more details about constrained optimization of sensor placement with various constraint region shapes.
\end{itemize}

\ppType{SparseSensing }{SparseSensing}
Expand All @@ -21,21 +23,44 @@ \subsubsection{SparseSensing}

\item \textbf{Classification} is the problem of predicting which category an example belongs to, given a set of training data (e.g. determining whether digital photos are of dogs or cats).
\end{itemize}
\nb{Currently, only reconstruction is implemented.}
In order to use the \xmlNode{Goal}, the user needs to provide the following subnodes:
\begin{itemize}
\item \xmlNode{features}, \xmlDesc{comma separated strings, required field}, features/inputs of the data model, i.e., possible sensor locations/IDs
\item \xmlNode{target}, \xmlDesc{comma separated strings, required field}, target of data model, i.e., response of interest sought to be reconstructed.
\item \xmlNode{measuredState}, \xmlDesc{comma separated strings, required field}, state Variable to be measured/sensed
\nb{Currently the algorithms can handle a single target}.
\item \xmlNode{basis} , \xmlDesc{string, optional field}, the type of basis onto which the data are projected: \xmlString{Identity}, \xmlString{SVD}, \xmlString{Random}. \default{SVD}
\item \xmlNode{basis}, \xmlDesc{string, optional field}, the type of basis onto which the data are projected: \xmlString{Identity}, \xmlString{SVD}, \xmlString{Random}. \default{SVD}
\item \xmlNode{nModes}, \xmlDesc{integer, required field}, the number of modes used to project the data.
\item \xmlNode{nSensors}, \xmlDesc{integer, required field}, the number of sensors used
\item \xmlNode{optimizer}, \xmlDesc{string, optional field}, the optimizer used to find the sensors: \xmlString{QR}, for the unconstrained case.
\item \xmlNode{optimizer}, \xmlDesc{string, optional field}, the optimizer used to find the sensors: \xmlString{QR}, for the unconstrained case, and \xmlString{GQR}, for the constrained case.
\item \xmlNode{seed}, \xmlDesc{integer, optional field}, the seed that is passed to the pysensors SSPOR fit function. If not specified if there are more sensors chosen then nModes, the sensors chosen will be different with each run.
\item \xmlNode{xValue}, \xmlDesc{string, required field}, variable plotted on the X-axis of the data model
\item \xmlNode{yValue}, \xmlDesc{string, required field}, variable plotted on the Y-axis of the data model
\item \xmlNode{zValue}, \xmlDesc{string, required field}, variable plotted on the Z-axis of the data model
\item \xmlNode{labels}, \xmlDesc{string or float list, required field when goal is classification}, labels/target for the classification case
\item \xmlNode{nConstSensors}, \xmlDesc{integer, required field when optimizer is GQR}, The number of constraint sensors for GQR optimizer
\item \xmlNode{constraintOption}, \xmlDesc{string. required field when optimizer is GQR}, The constraint the user wants to implement (max\_n, exact\_n, predetermined)
\item \xmlNode{ConstrainedRegions},
\item \xmlNode{type}, \xmlDesc{string, required field when optimizer is GQR}, type of Constrained Region shape the user wants- (Constraint can be a circle, parabola, ellipse, line, rectangle, square or user defined constraint too)
\item \xmlNode{classifier}, \xmlDesc{string, optional field}, The type of classifier used, default='LDA'
\item \xmlNode{center\_x}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is circle, ellipse}, The x co-ordinate of center of circle, ellipse
\item \xmlNode{center\_y}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is circle, ellipse}, The y co-ordinate of center of circle, ellipse
\item \xmlNode{radius}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is circle, ellipse}, The radius of circle, ellipse
\item \xmlNode{loc}, \xmlDesc{string, optional field}, whether the constraint region is inside or outside the shape defined as constraint
\item \xmlNode{width}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is ellipse}, Width of the ellipse
\item \xmlNode{height}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is ellipse}, Height of the ellipse
\item \xmlNode{angle}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is ellipse}, Angle of rotations of the ellipse
\item \xmlNode{x1}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is line}, X co-ordinate of one of the points that defines the line
\item \xmlNode{x2}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is line}, X co-ordinate of the other point that defines the line
\item \xmlNode{y1}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is line}, Y co-ordinate of one of the points that defines the line
\item \xmlNode{y2}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is line}, Y co-ordinate of the other point that defines the line
\item \xmlNode{h}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is parabola}, X coordinate of the vertex of the parabola we want to be constrained
\item \xmlNode{k}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is parabola}, Y coordinate of the vertex of the parabola we want to be constrained
\item \xmlNode{a}, \xmlDesc{float, required field when optimizer is GQR and ConstrainedRegions type is parabola}, X coordinate of the focus of the parabola
\item \xmlNode{xy_coords}, \xmlDesc{float list, required field when optimizer is GQR and ConstrainedRegions type is polygon}, an array consisting of tuples for (x,y) coordinates of points of the Polygon where N = No. of sides of the polygon
\end{itemize}
\end{itemize}

\textbf{Example:}
\textbf{Example: Unconstrained sensor placement for reconstruction}
\begin{lstlisting}[style=XML]
<Simulation>
...
Expand All @@ -44,7 +69,7 @@ \subsubsection{SparseSensing}
<PostProcessor name="mySPSL" subType="SparseSensing" verbosity="debug">
<Goal subType="reconstruction">
<features>X (m),Y (m),Temperature (K)</features>
<target>Temperature (K)</target>
<measuredState>Temperature (K)</measuredState>
<basis>SVD</basis> <!--default: SVD-->
<nModes>4</nModes> <!--default: opt, allows the algorithm to pick nModes-->
<nSensors>4</nSensors><!--default: opt, allows the algorithm to pick nSensors-->
Expand All @@ -56,3 +81,56 @@ \subsubsection{SparseSensing}
...
</Simulation>
\end{lstlisting}

\textbf{Example: Unconstrained sensor placement for classification}
\begin{lstlisting}[style=XML]
<Simulation>
...
<Models>
...
<PostProcessor name="mySPSL" subType="SparseSensing" verbosity="debug">
<Goal subType="classification">
<features>X (m),Y (m),Temperature (K), label</features>
<measuredState>Temperature (K)</measuredState>
<labels>label</labels>
<basis>SVD</basis>
<nModes>4</nModes>
<nSensors>4</nSensors>
<classifier>LDA</classifier>
</Goal>
</PostProcessor>
...
</Models>
...
</Simulation>
\end{lstlisting}

\textbf{Example: Constrained sensor placement for reconstruction with the constrained region being a circle}
\begin{lstlisting}[style=XML]
<Simulation>
...
<Models>
...
<PostProcessor name="mySPSL" subType="SparseSensing" verbosity="debug">
<Goal subType="reconstruction">
<features>X (m),Y (m),Temperature (K)</features>
<measuredState>Temperature (K)</measuredState>
<basis>SVD</basis>
<nModes>4</nModes>
<nSensors>4</nSensors>
<nConstSensors>0</nConstSensors>
<constraintOption>"exact_n"</constraintOption>
<ConstrainedRegions type = "circle">
<center_x>0.025</center_x>
<center_y>0</center_y>
<loc>'in'</loc>
<radius>0.02</radius>
</ConstrainedRegions>
<optimizer>GQR</optimizer>
</Goal>
</PostProcessor>
...
</Models>
...
</Simulation>
\end{lstlisting}
18 changes: 9 additions & 9 deletions doc/workshop/SparseSensing/exercises/testSPSLOptiTwist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
</RunInfo>

<Files>
<Input name="twistFile" type=""></Input><!-- Provide the csv file that contains the names of the samples files-->
<Input name="refDO" type=""></Input><!-- Provide the csv of the case onwhich you want to show the sensors i.e., maximum initial power (350 W) and maximum initial Temperature-->
<Input name="twistFile" type="">../../data/Perturbations.csv</Input><!-- Provide the csv file that contains the names of the samples files-->
<Input name="refDO" type="">../../data/350_330.csv</Input><!-- Provide the csv of the case onwhich you want to show the sensors i.e., maximum initial power (350 W) and maximum initial Temperature-->
</Files>

<Steps>
<IOStep name="LoadCSV">
<Input class="Files" type="">twistFile</Input>
<Input class="Files" type=""></Input><!--Fill in-->
<Input class="Files" type="">refDO</Input><!--Fill in-->
<Output class="DataObjects" type="HistorySet">TwistDO</Output>
<Output class="DataObjects" type="PointSet">myDO</Output>
</IOStep>
<PostProcess name="mySPpp">
<Input class="DataObjects" type="HistorySet">TwistDO</Input>
<Model class="Models" type="PostProcessor"></Model><!--Fill in-->
<Model class="Models" type="PostProcessor">mySPSL</Model><!--Fill in-->
<Output class="DataObjects" type="DataSet">outPP</Output>
</PostProcess>
<IOStep name="print">
Expand All @@ -45,12 +45,12 @@

<Models>
<PostProcessor name="mySPSL" subType="SparseSensing" verbosity="debug">
<Goal subType=""> <!--Fill in-->
<features></features><!--Fill in att variable names needed for training from the CSV-->
<target>Temperature (K)</target>
<Goal subType="reconstruction"> <!--Fill in-->
<features>X (m), Y (m), Temperature (K)</features><!--Fill in att variable names needed for training from the CSV-->
<measuredState>Temperature (K)</measuredState>
<basis>SVD</basis>
<nModes></nModes> <!--Try different modes-->
<nSensors></nSensors> <!--Try different number of sensors-->
<nModes>4</nModes> <!--Try different modes-->
<nSensors>4</nSensors> <!--Try different number of sensors-->
<optimizer>QR</optimizer>
</Goal>
</PostProcessor>
Expand Down
2 changes: 1 addition & 1 deletion doc/workshop/SparseSensing/inputs/testSPSLOptiTwist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<PostProcessor name="mySPSL" subType="SparseSensing" verbosity="debug">
<Goal subType="reconstruction">
<features>X (m),Y (m),Temperature (K)</features>
<target>Temperature (K)</target>
<measuredState>Temperature (K)</measuredState>
<basis>SVD</basis>
<nModes>4</nModes>
<nSensors>4</nSensors>
Expand Down
Loading