Skip to content

Add muntidim sbg input generation. #76

Description

@joaquinffernandez

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);
  }
.
.
.
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions