Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PI Problem Database
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marek Wiesner
PI Problem Database
Commits
eab2792f
Commit
eab2792f
authored
11 months ago
by
Marek Wiesner
Browse files
Options
Downloads
Patches
Plain Diff
Fix typos
parent
a099a066
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+3
-3
3 additions, 3 deletions
README.md
scripts/get_initial_state_infos.py
+12
-12
12 additions, 12 deletions
scripts/get_initial_state_infos.py
with
15 additions
and
15 deletions
README.md
+
3
−
3
View file @
eab2792f
...
...
@@ -106,12 +106,12 @@ To read the indices of measured states from the PCOMP file and write them to a J
./scripts/get_indices_of_measured_states.py DATASET_DIRECTORY MODELS_DIRECTORY OUTPUT_FILE
```
### Read initial state info
s
from the model files and write to JSON
### Read initial state info from the model files and write to JSON
To read info
s
regarding the initial states from the PCOMP file and write them to a JSON file, use the program
`scripts/get_initial_state_info
s
.py`
:
To read info regarding the initial states from the PCOMP file and write them to a JSON file, use the program
`scripts/get_initial_state_info.py`
:
```
Bash
./scripts/get_initial_state_info
s
.py DATASET_DIRECTORY MODELS_DIRECTORY OUTPUT_FILE
./scripts/get_initial_state_info.py DATASET_DIRECTORY MODELS_DIRECTORY OUTPUT_FILE
```
### Read constraint status from the model files and write to JSON
...
...
This diff is collapsed.
Click to expand it.
scripts/get_initial_state_infos.py
+
12
−
12
View file @
eab2792f
...
...
@@ -61,7 +61,7 @@ class InitialStateInfo:
return
json
.
dumps
(
self
.
to_dict
(),
indent
=
2
)
def
get_initial_state_info
s
(
modelFileName
:
Path
,
dataset
:
Dataset
)
->
tuple
[
bool
,
list
[
InitialStateInfo
]]:
def
get_initial_state_info
(
modelFileName
:
Path
,
dataset
:
Dataset
)
->
tuple
[
bool
,
list
[
InitialStateInfo
]]:
try
:
pcompModel
=
read_pcomp_model
(
modelFileName
,
get_pcomp_model_dimensions_from
(
dataset
))
except
VariablesDimensionError
as
err
:
...
...
@@ -73,7 +73,7 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
readingPcompModelWasSuccessful
=
True
initialStateInfo
s
:
list
[
InitialStateInfo
]
=
[]
initialStateInfo
:
list
[
InitialStateInfo
]
=
[]
for
function
in
pcompModel
.
functions
.
initialValues
:
if
len
(
function
.
body
)
!=
1
:
...
...
@@ -88,7 +88,7 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
if
is_number
(
returnStatement
):
value
=
float
(
returnStatement
)
logging
.
info
(
f
"
Found initial state value to be a fixed number:
{
value
}
"
)
initialStateInfo
s
.
append
(
initialStateInfo
.
append
(
InitialStateInfo
(
isParameter
=
False
,
isFixed
=
True
,
...
...
@@ -100,7 +100,7 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
constantIndex
=
[
c
.
name
.
lower
()
for
c
in
pcompModel
.
constants
].
index
(
returnStatement
)
value
=
pcompModel
.
constants
[
constantIndex
].
value
logging
.
info
(
f
"
Found initial state value to be a constant:
{
value
}
"
)
initialStateInfo
s
.
append
(
initialStateInfo
.
append
(
InitialStateInfo
(
isParameter
=
False
,
isFixed
=
True
,
...
...
@@ -115,7 +115,7 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
logging
.
info
(
f
"
Found initial state value to be a model parameter of the model:
{
dataset
.
modelParameterInfos
[
modelParameterIndex
].
name
}
"
)
initialStateInfo
s
.
append
(
initialStateInfo
.
append
(
InitialStateInfo
(
isParameter
=
True
,
isFixed
=
False
,
...
...
@@ -135,9 +135,9 @@ def get_initial_state_infos(modelFileName: Path, dataset: Dataset) -> tuple[bool
newline
=
'
\n
'
logging
.
info
(
f
"
{
dataset
.
name
}
: Found initial state info
s
: [
\n
{
f
'
,
{
newline
}
'
.join([f
'
{
info
}
'
for info in initialStateInfo
s
])
}
\n
]
"
)
f
"
{
dataset
.
name
}
: Found initial state info: [
\n
{
f
'
,
{
newline
}
'
.join([f
'
{
info
}
'
for info in initialStateInfo])
}
\n
]
"
)
return
readingPcompModelWasSuccessful
,
initialStateInfo
s
return
readingPcompModelWasSuccessful
,
initialStateInfo
def
read_broken_models
()
->
list
[
str
]:
...
...
@@ -146,7 +146,7 @@ def read_broken_models() -> list[str]:
def
main
()
->
int
:
parser
=
ArgumentParser
(
description
=
'
Read initial state info
s
from PCOMP file and write to JSON
'
)
parser
=
ArgumentParser
(
description
=
'
Read initial state info from PCOMP file and write to JSON
'
)
parser
.
add_argument
(
'
datasetFolder
'
,
type
=
str
,
help
=
'
Path to dataset folder
'
)
parser
.
add_argument
(
'
modelFolder
'
,
type
=
str
,
help
=
'
Path to model folder
'
)
parser
.
add_argument
(
'
outputFilePath
'
,
type
=
str
,
help
=
'
Path to output file
'
)
...
...
@@ -157,7 +157,7 @@ def main() -> int:
datasets
=
read_datasets_from_directory
(
args
.
datasetFolder
)
brokenModels
=
read_broken_models
()
initialStateInfo
s
:
dict
[
str
,
object
]
=
{}
initialStateInfo
:
dict
[
str
,
object
]
=
{}
for
dataset
in
datasets
:
if
not
dataset
.
modelType
==
ModelType
.
OrdinaryDifferentialEquations
:
...
...
@@ -169,9 +169,9 @@ def main() -> int:
continue
correspondingModeFileName
=
Path
(
args
.
modelFolder
)
/
f
"
{
dataset
.
name
}
.fun
"
readingModelSucceeded
,
initialStateInfo
=
get_initial_state_info
s
(
correspondingModeFileName
,
dataset
)
readingModelSucceeded
,
initialStateInfo
=
get_initial_state_info
(
correspondingModeFileName
,
dataset
)
initialStateInfo
s
[
dataset
.
name
]
=
{
initialStateInfo
[
dataset
.
name
]
=
{
"
readingModelSucceeded
"
:
readingModelSucceeded
,
"
initialStateInfo
"
:
[
info
.
to_dict
()
for
info
in
initialStateInfo
]
}
...
...
@@ -180,7 +180,7 @@ def main() -> int:
outputFolder
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
with
Path
(
args
.
outputFilePath
).
open
(
"
w
"
)
as
outfile
:
outfile
.
write
(
json
.
dumps
(
initialStateInfo
s
,
indent
=
4
))
outfile
.
write
(
json
.
dumps
(
initialStateInfo
,
indent
=
4
))
return
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment