<commit_before>#include "variable.h"

#include <string>
#include <sstream>

#include "cyc_limits.h"

// -----------------------------------------------------------------------------
int cyclus::Variable::next_id_ = 0;

// -----------------------------------------------------------------------------
cyclus::Variable::Variable(Bound l, Bound u, VarType t)
    : id_(next_id_++),
      lbound_(l),
      ubound_(u),
      type_(t) {
  std::stringstream ss;
  ss << "var_" << id_;
  name_ = ss.str();
}

// -----------------------------------------------------------------------------
int cyclus::Variable::id() {
  return id_;
}

// -----------------------------------------------------------------------------
cyclus::Variable::VarType cyclus::Variable::type() {
  return type_;
}

// -----------------------------------------------------------------------------
cyclus::Variable::Bound cyclus::Variable::lbound() {
  return lbound_;
}

// -----------------------------------------------------------------------------
cyclus::Variable::Bound cyclus::Variable::ubound() {
  return ubound_;
}

// -----------------------------------------------------------------------------
std::string cyclus::Variable::name() {
  return name_;
}

// -----------------------------------------------------------------------------
void cyclus::Variable::set_name(std::string name) {
  name_ = name;
}

// -----------------------------------------------------------------------------
void cyclus::Variable::set_value(boost::any v) {
  value_ = v;
}

// -----------------------------------------------------------------------------
boost::any cyclus::Variable::value() {
  return value_;
}

// -----------------------------------------------------------------------------
cyclus::LinearVariable::LinearVariable(Bound lb, Bound ub)
    : Variable(lb, ub, LINEAR),
      lbound_val_(-cyclus::kLinBoundLimit),
      ubound_val_(cyclus::kLinBoundLimit) 
{ }

// -----------------------------------------------------------------------------
cyclus::LinearVariable::LinearVariable(double lb_val, Bound ub)
    : Variable(FINITE, ub, LINEAR),
      lbound_val_(lb_val),
      ubound_val_(cyclus::kLinBoundLimit) 
{ }
  
// -----------------------------------------------------------------------------
cyclus::LinearVariable::LinearVariable(Bound lb, double ub_val)
    : Variable(lb, FINITE, LINEAR),
      lbound_val_(-cyclus::kLinBoundLimit),
      ubound_val_(ub_val) 
{ } 

// -----------------------------------------------------------------------------
cyclus::LinearVariable::LinearVariable(double lb_val, double ub_val)
    : Variable(FINITE, FINITE, LINEAR),
      lbound_val_(lb_val),
      ubound_val_(ub_val) 
{ }

// -----------------------------------------------------------------------------
double cyclus::LinearVariable::lbound_val() {
  return lbound_val_;
}

// -----------------------------------------------------------------------------
double cyclus::LinearVariable::ubound_val() {
  return ubound_val_;
}

// -----------------------------------------------------------------------------
cyclus::IntegerVariable::IntegerVariable(Bound lb, Bound ub)
    : Variable(lb, ub, INT),
      lbound_val_(-cyclus::kIntBoundLimit),
      ubound_val_(cyclus::kIntBoundLimit) 
{ }

// -----------------------------------------------------------------------------
cyclus::IntegerVariable::IntegerVariable(int lb_val, Bound ub)
    : Variable(FINITE, ub, INT),
      lbound_val_(lb_val),
      ubound_val_(cyclus::kIntBoundLimit) 
{ }
  
// -----------------------------------------------------------------------------
cyclus::IntegerVariable::IntegerVariable(Bound lb, int ub_val)
    : Variable(lb, FINITE, INT),
      lbound_val_(-cyclus::kIntBoundLimit),
      ubound_val_(ub_val) 
{ } 

// -----------------------------------------------------------------------------
cyclus::IntegerVariable::IntegerVariable(int lb_val, int ub_val)
    : Variable(FINITE, FINITE, INT),
      lbound_val_(lb_val),
      ubound_val_(ub_val) 
{ } 

// -----------------------------------------------------------------------------
int cyclus::IntegerVariable::lbound_val() {
  return lbound_val_;
}

// -----------------------------------------------------------------------------
int cyclus::IntegerVariable::ubound_val() {
  return ubound_val_;
}

// -----------------------------------------------------------------------------
std::pair<int, int> cyclus::GetIntBounds(
    cyclus::VariablePtr v) {
  using cyclus::IntegerVariable;
  IntegerVariable* clone = dynamic_cast<IntegerVariable*>(v.get());
  return std::pair<int, int>(clone->lbound_val(), clone->ubound_val());
}

// -----------------------------------------------------------------------------
std::pair<double, double> cyclus::GetLinBounds(
    cyclus::VariablePtr v) {
  using cyclus::LinearVariable;
  LinearVariable* clone = dynamic_cast<LinearVariable*>(v.get());
  return std::pair<double, double>(clone->lbound_val(), clone->ubound_val());
}<commit_msg>put variable implementation file in cyclus namespace<commit_after>#include "variable.h"

#include <string>
#include <sstream>

#include "cyc_limits.h"

namespace cyclus {

// -----------------------------------------------------------------------------
int Variable::next_id_ = 0;

// -----------------------------------------------------------------------------
Variable::Variable(Bound l, Bound u, VarType t)
    : id_(next_id_++),
      lbound_(l),
      ubound_(u),
      type_(t) {
  std::stringstream ss;
  ss << "var_" << id_;
  name_ = ss.str();
}

// -----------------------------------------------------------------------------
int Variable::id() {
  return id_;
}

// -----------------------------------------------------------------------------
Variable::VarType Variable::type() {
  return type_;
}

// -----------------------------------------------------------------------------
Variable::Bound Variable::lbound() {
  return lbound_;
}

// -----------------------------------------------------------------------------
Variable::Bound Variable::ubound() {
  return ubound_;
}

// -----------------------------------------------------------------------------
std::string Variable::name() {
  return name_;
}

// -----------------------------------------------------------------------------
void Variable::set_name(std::string name) {
  name_ = name;
}

// -----------------------------------------------------------------------------
void Variable::set_value(boost::any v) {
  value_ = v;
}

// -----------------------------------------------------------------------------
boost::any Variable::value() {
  return value_;
}

// -----------------------------------------------------------------------------
LinearVariable::LinearVariable(Bound lb, Bound ub)
    : Variable(lb, ub, LINEAR),
      lbound_val_(-kLinBoundLimit),
      ubound_val_(kLinBoundLimit) 
{ }

// -----------------------------------------------------------------------------
LinearVariable::LinearVariable(double lb_val, Bound ub)
    : Variable(FINITE, ub, LINEAR),
      lbound_val_(lb_val),
      ubound_val_(kLinBoundLimit) 
{ }
  
// -----------------------------------------------------------------------------
LinearVariable::LinearVariable(Bound lb, double ub_val)
    : Variable(lb, FINITE, LINEAR),
      lbound_val_(-kLinBoundLimit),
      ubound_val_(ub_val) 
{ } 

// -----------------------------------------------------------------------------
LinearVariable::LinearVariable(double lb_val, double ub_val)
    : Variable(FINITE, FINITE, LINEAR),
      lbound_val_(lb_val),
      ubound_val_(ub_val) 
{ }

// -----------------------------------------------------------------------------
double LinearVariable::lbound_val() {
  return lbound_val_;
}

// -----------------------------------------------------------------------------
double LinearVariable::ubound_val() {
  return ubound_val_;
}

// -----------------------------------------------------------------------------
IntegerVariable::IntegerVariable(Bound lb, Bound ub)
    : Variable(lb, ub, INT),
      lbound_val_(-kIntBoundLimit),
      ubound_val_(kIntBoundLimit) 
{ }

// -----------------------------------------------------------------------------
IntegerVariable::IntegerVariable(int lb_val, Bound ub)
    : Variable(FINITE, ub, INT),
      lbound_val_(lb_val),
      ubound_val_(kIntBoundLimit) 
{ }
  
// -----------------------------------------------------------------------------
IntegerVariable::IntegerVariable(Bound lb, int ub_val)
    : Variable(lb, FINITE, INT),
      lbound_val_(-kIntBoundLimit),
      ubound_val_(ub_val) 
{ } 

// -----------------------------------------------------------------------------
IntegerVariable::IntegerVariable(int lb_val, int ub_val)
    : Variable(FINITE, FINITE, INT),
      lbound_val_(lb_val),
      ubound_val_(ub_val) 
{ } 

// -----------------------------------------------------------------------------
int IntegerVariable::lbound_val() {
  return lbound_val_;
}

// -----------------------------------------------------------------------------
int IntegerVariable::ubound_val() {
  return ubound_val_;
}

// -----------------------------------------------------------------------------
std::pair<int, int> GetIntBounds(VariablePtr v) {
  IntegerVariable* clone = dynamic_cast<IntegerVariable*>(v.get());
  return std::pair<int, int>(clone->lbound_val(), clone->ubound_val());
}

// -----------------------------------------------------------------------------
std::pair<double, double> GetLinBounds(VariablePtr v) {
  LinearVariable* clone = dynamic_cast<LinearVariable*>(v.get());
  return std::pair<double, double>(clone->lbound_val(), clone->ubound_val());
}

} // namespace cyclus
{'fraction_non_alphanumeric': 0.4781846312532233, 'fraction_numerical': 0.00020629190304280557, 'mean_word_length': 0.9885151763740772, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7271477', 'n_tokens_mistral': 2261, 'n_tokens_neox': 2186, 'n_words': 360}