Exemplo n.º 1
0
void MMSBModel::InitModelState() {
  /// community assignment
  for (auto& id_v : vertices_) {
    const VIndex i = id_v.first;
    Vertex* v = id_v.second;
    const unordered_map<VIndex, CIndex>& neighbor_z = v->neighbor_z();
    for (const auto& nz : neighbor_z) {
      VIndex j = nz.first;
      if (i >= j) continue;

      CIndex z = Context::randUInt64() % K_;
      v->SetZ(j, z);
      auto vj = vertices_.find(j);
      if (vj != vertices_.end()) { // vj is on the local worker
        vj->second->SetZ(i, z);
      } else { // vj is on another worker, send msg
        SendZMsg(j, i, z);
      }
    }
  }

  petuum::PSTableGroup::GlobalBarrier();
  SetZfromMsg();

  /// global param
  fill(lambda_0_.begin(), lambda_0_.end(), eta_.first);  
  fill(lambda_1_.begin(), lambda_1_.end(), eta_.second);  

  LOG(INFO) << "Init model state done.";
}
Exemplo n.º 2
0
const Vertex Matrix3D::operator*(const Vertex &p) const
{
	/*
		Multiplying a vertex by a matrix
	*/

	// Need to update this

	Vertex temp;

	temp.SetX((this->_m[0][0]  * p.GetX()) + (this->_m[0][1]  * p.GetY()) + (this->_m[0][2] * p.GetZ()) + (this->_m[0][3] * p.GetW()));
	temp.SetY((this->_m[1][0]  * p.GetX()) + (this->_m[1][1]  * p.GetY()) + (this->_m[1][2] * p.GetZ()) + (this->_m[1][3] * p.GetW()));
	temp.SetZ((this->_m[2][0]  * p.GetX()) + (this->_m[2][1]  * p.GetY()) + (this->_m[2][2] * p.GetZ()) + (this->_m[2][3] * p.GetW()));
	temp.SetW((this->_m[3][0]  * p.GetX()) + (this->_m[3][1]  * p.GetY()) + (this->_m[3][2] * p.GetZ()) + (this->_m[3][3] * p.GetW()));

	temp.GetColor().SetValue(p.GetColor().GetValue());

	return temp;

}