CIFASIS / CIFASIS/modelicacc

Add muntidim sbg input generation.

Open
#76 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
20
Forks
10
PR merge metrics
No merged PRs in 30d

Description

Currently the input for SBG binary eval only handles one dimension. Extend with the previous code for multi--dim intervals.
```
void GenerateSBGInput::addDims(size_t max_dim, size_t exp_dim, SBG::MultiInterval& intervals, int offset)
{
if (max_dim > exp_dim) {
for (size_t i = exp_dim; i < max_dim; i++) {
Interval interval(offset, 1, offset);
intervals.addInter(interval);
}
}
}

void GenerateSBGInput::addDims(size_t max_dim, size_t exp_dim, ORD_REALS& constant, ORD_REALS& slope)
{
ORD_REALS::iterator constant_it = constant.end();
ORD_REALS::iterator slope_it = slope.end();
if (max_dim > exp_dim) {
for (size_t i = exp_dim; i < max_dim; i++) {
constant_it = constant.insert(constant_it, 0);
slope_it = slope.insert(slope_it, 0);
}
}
}
```

```
int GenerateSBGInput::generatePWLMaps(Expression exp, int offset, std::string eq_id, size_t max_dim, IndexList dom, int edge_id)
{
.
.
.
if (indexes.empty()) { // Scalar variable.
addOffset(edge_id, "M1", 0, node_id);
_m1_slopes.push_back(1);
addDims(max_dim, 1, constant_pwl_map_u, slope_pwl_map_u);
} else {
addDims(max_dim, indexes.size(), constant_pwl_map_u, slope_pwl_map_u);
}
for (const auto& idx : dom) {
Real set_vertex_init = getMin(idx);
addOffset(edge_id, "M2", 0, eq_node_id);
}
if (dom.empty()) { // Scalar variable.
addOffset(edge_id, "M2", 0, eq_node_id);
addDims(max_dim, 1, constant_pwl_map_u, slope_pwl_map_u);
} else {
addDims(max_dim, dom.minElem().size(), constant_pwl_map_eqs, slope_pwl_map_eqs);
}
.
.
.
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.