void Resource<Dim, Type, Data>::update(double _time) { logger(Logger::PROGRESS) << "Resource : update"; if(assignment != nullptr) { logger(Logger::INFO) << "Resource : assignment found."; if(Resource<Dim, Type, Data>::getCoordonates() == static_cast<TaskSpot<Dim, Type>*>(assignment)->getCoordonates()) { logger(Logger::INFO) << "Resource : Update taskSpot."; assignment->update(_time); } else if(path != nullptr) { logger(Logger::INFO) << "Resource : moving."; move(_time); } else { logger(Logger::INFO) << "Resource : path calculation."; path = spa(Resource<Dim, Type, Data>::getCoordonates(), static_cast<TaskSpot<Dim, Type>*>(assignment)->getCoordonates()); } } else { logger(Logger::INFO) << "Resource : no assigment / wait."; } }
Complex gamgamgamgam_mmpp(int i1,int i2,int i3,int i4) { return spa(i1,i2)*spa(i1,i2)*spa(i1,i2)/spa(i2,i3)/spa(i3,i4)/spa(i4,i1) * ( 0.5 * sij(i2,i3)/pow(sij(i1,i2),3) * ( pow(sij(i1,i3),2) + pow(sij(i2,i3),2) ) * ( pow(Clog(sij(i1,i3),sij(i2,i3)),2) + PISQ ) + sij(i2,i3)/sij(i1,i2)/sij(i1,i2) * (sij(i1,i3)-sij(i2,i3)) * ( Clog(sij(i1,i3),sij(i2,i3)) ) + sij(i2,i3)/sij(i1,i2) ) ; }
Matrix Matrix::operator*(const Matrix &other) const { if (numberOfColumns() != other.numberOfRows()) { throw std::runtime_error("Matrix::operator*(const Matrix &other): Dimensions of matrices do not match"); } Matrix result(numberOfRows(), other.numberOfColumns()); SparseAccumulator spa(numberOfRows()); for (index r = 0; r < numberOfRows(); ++r) { graph.forNeighborsOf(r, [&](node v, double w1){ other.graph.forNeighborsOf(v, [&](node u, double w2){ double value = w1 * w2; spa.scatter(value, u); }); }); spa.gather([&](node row, node column, double value){ result.graph.addEdge(row, column, value); }); spa.increaseRow(); } return result; }
Complex gamgamgamgam_mppp(int i1,int i2,int i3,int i4) { return spa(i1,i3)*spb(i2,i3)*spb(i3,i4) /spb(i1,i3)/spa(i2,i3)/spa(i3,i4) ; }
Complex gamgamgamgam_mmmm(int i1,int i2,int i3,int i4) { return spa(i3,i4)*spa(i3,i4)/spb(i1,i2)/spb(i1,i2) ; }
Complex qqggamgam_tree_pmmpp(int i1, int i2, int i3, int i4, int i5) { return -spa(i1,i2)*spa(i2,i3)*spa(i2,i3)/spa(i1,i4)/spa(i1,i5)/spa(i2,i4)/spa(i2,i5); }
int main(int argc, char *argv[]) { std::string filename(boost::archive::tmpdir()); filename += "/testfile"; // create a new shared pointer to ta new object of type A boost::shared_ptr<A> spa(new A); boost::shared_ptr<A> spa1; spa1 = spa; display(spa, spa1); // serialize it { std::ofstream ofs(filename.c_str()); boost::archive::text_oarchive oa(ofs); oa << spa; oa << spa1; } // reset the shared pointer to NULL // thereby destroying the object of type A spa.reset(); spa1.reset(); display(spa, spa1); // restore state to one equivalent to the original // creating a new type A object { // open the archive std::ifstream ifs(filename.c_str()); boost::archive::text_iarchive ia(ifs); // restore the schedule from the archive ia >> spa; ia >> spa1; } display(spa, spa1); spa.reset(); spa1.reset(); std::cout << std::endl; std::cout << std::endl; std::cout << "New tests" << std::endl; ///////////////// // ADDITION BY DT // create a new shared pointer to ta new object of type A spa = boost::shared_ptr<A>(new B); spa1 = spa; display(spa, spa1); // serialize it { std::ofstream ofs(filename.c_str()); boost::archive::text_oarchive oa(ofs); oa.register_type(static_cast<B *>(NULL)); oa.register_type( static_cast< boost::detail::sp_counted_base_impl< B *, boost::checked_deleter<B> > * >(NULL) ); oa << spa; oa << spa1; } // reset the shared pointer to NULL // thereby destroying the object of type B spa.reset(); spa1.reset(); display(spa, spa1); // restore state to one equivalent to the original // creating a new type B object { // open the archive std::ifstream ifs(filename.c_str()); boost::archive::text_iarchive ia(ifs); // restore the schedule from the archive ia.register_type(static_cast<B *>(NULL)); ia.register_type( static_cast< boost::detail::sp_counted_base_impl< B *, boost::checked_deleter<B> > * >(NULL) ); ia >> spa; ia >> spa1; } display(spa, spa1); /////////////// std::remove(filename.c_str()); // obj of type A gets destroyed // as smart_ptr goes out of scope return 0; }
Complex qqgamgam_tree_mpmp(int i1, int i2, int i3, int i4) { return pow(spa(i1,i3),2)/spa(i1,i4)/spa(i2,i4); }