Skip to content

Commit

Permalink
Offline model building: system_structure and related functionality (#542
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kyllingstad authored Mar 31, 2020
1 parent d644b19 commit ded0150
Show file tree
Hide file tree
Showing 11 changed files with 1,206 additions and 3 deletions.
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

0 comments on commit ded0150

Please sign in to comment.