Ejemplo n.º 1
0
//--------------------------------------------------------------------------
void Omu_Integrator::setup_struct(int k,
				  const Omu_VariableVec &x,
				  const Omu_VariableVec &u,
				  const Omu_DependentVec &Ft)
{
  // initialize Jacobians for high-level integrator interface

  if (k >= _K) {
    m_error(E_INTERN, "Omu_Integrator::setup_struct"
	    " that was called with wrong integrator setup");
  }

  int i;
  Omu_DepVec &Fc = _Fcs[k];

  init_dims(k, x, u, Ft);

  Fc.size(_n, _n, 0, _n, 0, _nx+_nu);
  m_move(Ft.Jx, _nd, _nd, _n, _n, Fc.Jx, 0, 0);
  m_move(Ft.Jdx, _nd, _nd, _n, _n, Fc.Jdx, 0, 0);
  m_zero(Fc.Jq); // zero Jq wrt. continuous states as Jx gets chained with Sx
  m_move(Ft.Jx, _nd, 0, _n, _nd, Fc.Jq, 0, 0);
  m_move(Ft.Ju, _nd, 0, _n, _nu, Fc.Jq, 0, _nx);

  Fc.c_setup = true;
  for (i = 0; i < _n; i++) {
    int wrt = 0;
    if (Ft.is_linear_element(_nd + i, Omu_Dependent::WRT_x))
      wrt |= Omu_Dependent::WRT_x;
    if (Ft.is_linear_element(_nd + i, Omu_Dependent::WRT_dx))
      wrt |= Omu_Dependent::WRT_dx;
    if ((_nd == 0 || Ft.is_linear_element(_nd + i, Omu_Dependent::WRT_x)) &&
	Ft.is_linear_element(_nd + i, Omu_Dependent::WRT_u))
      wrt |= Omu_Dependent::WRT_q;
    Fc.set_linear_element(i, wrt);
  }
  Fc.analyze_struct();
  Fc.c_setup = false;
}
Ejemplo n.º 2
0
//--------------------------------------------------------------------------
void Omu_Integrator::init_stage(int k,
				const Omu_VariableVec &x,
				const Omu_VariableVec &u,
				const Omu_DependentVec &Ft,
				bool sa)
{
  if (k >= _K) {
    m_error(E_INTERN, "Omu_Integrator::init_stage"
	    " that was called with wrong integrator setup");
  }

  // initialize dimensions
  init_dims(k, x, u, Ft);

  _sa = sa;

  if ((int)(_Fcs[k]->dim) != _n) {
    m_error(E_INTERN, "Omu_Integrator::solve"
	    " that was called with wrong integrator setup of stage");
  }

  // initialize call arguments for sys->continuous
  _ut.resize(_nu);
  _dxt.resize(_nxt, _nx, _nu);
  v_zero(_dxt); // zero time derivative of discrete states

  // initialize call arguments for high-level integrator interface
  _xc.resize(_n, 0, 0, _nq);
  _dxc.resize(_n, 0, 0, _nq);
  _q.resize(_nq);

  // call high-level init
  init(k, _xc, _q, _Fcs[k], sa);

  // call depreciated init_stage
  init_stage(k, (Omu_SVarVec &)x, u, sa);
}
Ejemplo n.º 3
0
bool Clustering::initialize() {
	if (!m_conf.parse()) 
		EXIT_ERROR("Parse error in config.in!");

    m_threshold = atof(m_conf.get("threshold").c_str());
    if (m_threshold == -1)
        EXIT_ERROR("threshold is not set in config.in!");
    
    string data_pt = m_conf.get("data_pt");
    if (data_pt.empty()) 
		EXIT_ERROR("data_pt is not set in config.in!");
        
    read_docs(data_pt.c_str());
    if (m_docs.empty())
        EXIT_ERROR2("no queries read from ", data_pt.c_str());
    cout << "read queries, size = " << m_docs.size() <<endl;

    init_dims();
    if (m_dims.empty())
        EXIT_ERROR("Bad init cluster data format, feature dimension is zero!");
    cout << "DimArray initialized, size = " << m_dims.size() <<endl;
    
    return true;
}