Beispiel #1
0
void ChemoPopComposer::setupAgentHierarchy() {
	// set children of maestro
	if (this->number_of_cells > 0) {
		for (int i=1;i<=this->number_of_cells; i++) {
			Agent *cell = orchestra.at(i);
			maestro->addChild(cell->getAgentId());
			cell->setParent(maestro->getAgentId());
			cell->addSpecialAgent(this->special_agents[0]->getAgentId());
		}
	}
	maestro->addSpecialAgent(this->special_agents[0]->getAgentId());
}
Beispiel #2
0
Creator::Creator()
{
	//composing the world hierarchy(i havent figured out the composer yet)
	WorldFactory *WF = new WorldFactory();
	Agent *W = WF->createAgent();
	BacteriumFactory *BF = new BacteriumFactory();
	Agent *B = BF->createAgent();
	W->addChild(B->getAgentId());
	B->setParent(W->getAgentId());
	//dvorak could do better, I suppose

	//initializing the position, ligand_level,ligand and phosphorylation level
	srand(time(NULL));
	int position = rand()%3;
	int ligand_level = rand()%3;
	double phosph = 0;
	double ligand;
	switch (ligand_level) {
		case 0: ligand = 10; break;
		case 1: ligand = 1000; break;
		case 2: ligand = 100000; break;
	}
	cout << endl<<endl<<endl;
	cout << "Bacterium is in box "<<position<<endl;
	cout << "The ligand level is "<<ligand_level<<endl;
	cout << "The ligand conc is "<<ligand<<endl;
	cout << "The phosph conc is "<<phosph <<endl;

	//Initializing the Databases
	IntegerData *data1 = new IntegerData("Ligand Level",ligand_level);
	DoubleData *data2 = new DoubleData("Phosph Conc", phosph);
	W->getDatabase()->addData(data1->getName(),data1);
	W->getDatabase()->addData(data2->getName(),data2);
	DoubleData *data3 = new DoubleData("Ligand Conc",ligand);
	DoubleData *data4 = new DoubleData("Phosph Conc", phosph);
	B->getDatabase()->addData(data3->getName(),data3);
	B->getDatabase()->addData(data4->getName(),data4);
}
void BlindAgentNotifyWorldThatNewAgentIsBorn::placeMessage(int destID) {
	//check if I have to give birth or not
	if(birthFlag->getBool())
	{
		birthFlag->setBool(false);

		// if the death simulator determined death, then do not create the birth message
		if(deathFlag->getBool()) return;

		//get the agentfactory, and use it to create an agent
		AgentFactory *af = Registrar::getSystemRegistrar()->getAgentFactory(1);
		Agent *a = af->createAgent();

		// has the same parent
		// NOTE: the parent is the top level agent in the hierarchy of agents,
		// not the agent that gave birth!
		a->setParent(source->getParentId());

		// has the same special agents
		for(unsigned int s=0; s<source->getNumOfSpecialAgents(); s++)
			a->addSpecialAgent(source->getSpecialAgentId(s));

		// needs the same communicator, of course, of course
		a->addCommunicator(source->getCommunicator());

		// set the other properties of agent 'a' based on the source exactly...
		a->copyDatabaseInformationFromExistingAgent(this->source);


		// CLEARLY A HACK!!  CHANGE THIS AT SOME POINT TO DUPLICATE SIMULATORS
		// replace the movement simulator with the correct one
		if (((BoolData*) a->getDatabase()->getDataItem("is_levy"))->getBool()) {
			LevyRunLengthSimulator *levy = new LevyRunLengthSimulator();
			a->replaceSimulator(0,levy);
		} else {
			ExponentialRunLengthSimulator *expo = new ExponentialRunLengthSimulator();
			a->replaceSimulator(0,expo);
		}



		// ANOTHER HACK !! TIME TO NEXT OUTPUT IS OFF WHEN WE GET HERE, SO WE MUST UPDATE
		DoubleData *t  = (DoubleData *) a->getDatabase()->getDataItem("celltime");
		//DoubleData *oi = (DoubleData *) a->getDatabase()->getDataItem("outputinterval");
		//DoubleData *no = (DoubleData*) a->getDatabase()->getDataItem("nextOutputTime");

		DoubleData *dt = (DoubleData *) a->getDatabase()->getDataItem("dt");
		t->setDouble(t->getDouble()-dt->getDouble());


		//register agent a
		Message *specialMssg = new Message();
		specialMssg->setAction(ChemoPopActionIDs::SPECIAL_AGENT_UPDATE_BLIND_AGENT_COUNT_ACTION_ID);
		specialMssg->setArgument(new IntegerData("ChangeInBlindAgentNumber",1));
		Registrar::getSystemRegistrar()->registerNewAgentAndSendMessageToSpecialAgent(a,specialMssg);

		// Now, send the message to the world!!
		Message *msg = new Message();
		msg->setAction(ChemoPopActionIDs::UPDATE_WORLD_BLIND_AGENT_BIRTH_ACTION_ID);
		msg->setDestinationID(destID);

		//pass my agentID (the mother) and the new agent ID (the baby)
		TVectorData<int> *info = new TVectorData<int>("new_cell_info","tvectordata_int");
		info->addElementToEnd(this->source->getAgentId());
		info->addElementToEnd(a->getAgentId()); // get new AgentID !!!
		msg->setArgument(info);

		source->placeMessageInOutbox(msg);

	}
}