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

Offline model building: system_structure and related functionality #542

Merged
merged 57 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
812db2c
WIP on system_structure
kyllingstad Sep 23, 2019
e18df88
More WIP on system_structure
kyllingstad Oct 4, 2019
ab5721f
Even more WIP on system_structure
kyllingstad Oct 14, 2019
a05a40d
WIP
kyllingstad Oct 14, 2019
c7e3743
Move visitor to utility header
kyllingstad Oct 14, 2019
654d481
Merge remote-tracking branch 'origin/feature/split-off-visitor' into …
kyllingstad Oct 14, 2019
fec0f81
WIP: Initial values
kyllingstad Oct 16, 2019
5283416
WIP: Add docs and update test
kyllingstad Oct 17, 2019
13b1c1f
Fix typo
kyllingstad Oct 17, 2019
17d8581
Remove half-written code in remote_fmu.cpp
kyllingstad Oct 17, 2019
b12ce6d
Merge remote-tracking branch 'origin/master' into feature/114-offline…
kyllingstad Oct 17, 2019
8d11273
Improve SSP parser "default experiment" handling
kyllingstad Oct 17, 2019
1d85243
Handle both SSP dir and filename
kyllingstad Oct 17, 2019
83a9b6d
Update other SSP tests too
kyllingstad Oct 17, 2019
99fb9ff
Drop source() from cse::model again
kyllingstad Oct 19, 2019
08acc94
Merge remote-tracking branch 'origin/master' into feature/114-offline…
kyllingstad Oct 19, 2019
2ed0880
Fix load_ssp() documentation
kyllingstad Oct 30, 2019
e02f445
Document simulator name rule, improve error msg.
kyllingstad Oct 30, 2019
49bceed
Use ':' to separate simulator and variable name
kyllingstad Oct 30, 2019
87157fd
Rename variable_qname to full_variable_name
kyllingstad Oct 30, 2019
f077da0
If-with-initialiser FTW
kyllingstad Oct 30, 2019
282e063
Merge remote-tracking branch 'origin/master' into feature/114-offline…
kyllingstad Nov 1, 2019
377c23b
Add function API and example function
kyllingstad Jan 10, 2020
9ce9695
WIP
kyllingstad Jan 15, 2020
9db2b1a
Complete(?) function API
kyllingstad Jan 23, 2020
cc884d8
Remove connections
kyllingstad Jan 23, 2020
3393996
Minor fixes here and there, update tests
kyllingstad Jan 24, 2020
096571e
NOMINMAX again
kyllingstad Jan 27, 2020
5a17639
Add function unittests
kyllingstad Jan 27, 2020
cd66c82
Add forgotten function_unittests
kyllingstad Jan 28, 2020
6e90d1a
Fix some issues from code review
kyllingstad Feb 4, 2020
a80917b
Fix more review comments
kyllingstad Feb 4, 2020
837b189
Fix MSVC warning
kyllingstad Feb 4, 2020
6709168
Fix decimation factor calculation
kyllingstad Feb 4, 2020
b88a126
Calculate functions before stepping simulators
kyllingstad Feb 4, 2020
84a3d85
Revert to evaluating functions at end of step
kyllingstad Feb 20, 2020
dc25263
Documentation-o-rama
kyllingstad Feb 20, 2020
cdd29fb
Split function_type_description
kyllingstad Feb 21, 2020
0fa79d7
Rename function variable getters & setters
kyllingstad Feb 21, 2020
f9fa740
Support boolean and string variables in functions
kyllingstad Feb 21, 2020
a50059e
WIP on tests
kyllingstad Mar 5, 2020
dc0c527
Fix mock_slave and lots of magic numbers
kyllingstad Mar 16, 2020
5cd2311
Merge branch bugfix/538-... and complete tests
kyllingstad Mar 17, 2020
6dad16e
Fix MSVC warnings
kyllingstad Mar 17, 2020
dcb68ca
Merge branch 'master' into feature/114-offline-model-building
kyllingstad Mar 19, 2020
870bfd9
Merge branch 'feature/464-connection-introspection' into feature/114-…
kyllingstad Mar 19, 2020
f1a4d93
Rename `scalar_connection` to `connection`
kyllingstad Mar 20, 2020
5e1702c
Use "entity" instead of "simulator"
kyllingstad Mar 20, 2020
0232093
Define alias for function parameter maps
kyllingstad Mar 23, 2020
b9d50a7
Public enums for function parameter indexes
kyllingstad Mar 23, 2020
f79c0a5
Complete support for functions in system_structure
kyllingstad Mar 23, 2020
136be4b
Merge branch 'feature/464-connection-introspection' into feature/114-…
kyllingstad Mar 23, 2020
4f13557
Move implementation of to_text() to cpp file
kyllingstad Mar 23, 2020
5979e25
Merge remote-tracking branch 'origin/master' into feature/464-connect…
kyllingstad Mar 25, 2020
747f86b
Merge branch 'feature/464-connection-introspection' into feature/114-…
kyllingstad Mar 25, 2020
e695ae5
Support step size hints for simulators
kyllingstad Mar 25, 2020
e0edd25
Merge branch 'master' into feature/114-offline-model-building
kyllingstad Mar 27, 2020
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
3 changes: 3 additions & 0 deletions include/cse/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ enum class errc
/// Simulation error
simulation_error,

/// Invalid system structure (e.g. an invalid variable connection)
invalid_system_structure,

/// ZIP file error
zip_error
};
Expand Down
29 changes: 29 additions & 0 deletions include/cse/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
#include <cse/async_slave.hpp>
#include <cse/function/function.hpp>
#include <cse/model.hpp>
#include <cse/system_structure.hpp>

#include <boost/fiber/future.hpp>
#include <boost/functional/hash.hpp>

#include <memory>
#include <optional>
#include <sstream>
#include <unordered_map>


namespace cse
Expand Down Expand Up @@ -311,5 +313,32 @@ class execution
};


/// Maps entity names to simulator/function indices in an `execution`.
struct entity_index_maps
{
/// Mapping of simulator names to simulator indices.
std::unordered_map<std::string, simulator_index> simulators;

/// Mapping of function names to function indices.
std::unordered_map<std::string, function_index> functions;
};


/**
* Adds simulators and connections to an execution, and sets initial values,
* according to a predefined system structure description.
*
* This function may be called multiple times for the same `execution`, as
* long as there is no conflict between the different `system_structure`
* objects.
*
* \returns
* Mappings between entity names and their indexes in the execution.
*/
entity_index_maps inject_system_structure(
execution& exe,
const system_structure& sys,
const variable_value_map& initialValues);

} // namespace cse
#endif // header guard
13 changes: 13 additions & 0 deletions include/cse/function/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,18 @@ T get_function_parameter(
}


/**
* Returns a `function_description` with the same contents as the
* `function_description` part of `functionTypeDescription`, but with
* all placeholders replaced by actual parameter values.
*
* The `parameterValues` map *must* contain values for all placeholders
* in `functionTypeDescription`. Otherwise, an exception is thrown.
*/
function_description substitute_function_parameters(
const function_type_description& functionTypeDescription,
const function_parameter_value_map& parameterValues);


} // namespace cse
#endif // header guard
Loading