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

Add muntidim sbg input generation. #76

Open
joaquinffernandez opened this issue Aug 2, 2024 · 0 comments
Open

Add muntidim sbg input generation. #76

joaquinffernandez opened this issue Aug 2, 2024 · 0 comments

Comments

@joaquinffernandez
Copy link
Collaborator

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);
  }
.
.
.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

1 participant