Пример #1
0
/* convert from L1 to L3 */
void 
Model::convertL3ToL2 (bool strict)
{
  dealWithModelUnits();

  dealWithStoichiometry();

  dealWithEvents(strict);

  for (unsigned int i = 0; i < getNumReactions(); i++)
  {
    Reaction *r = getReaction(i);
    if (r->isSetKineticLaw())
    {
      KineticLaw *kl = r->getKineticLaw();
      for (unsigned int j = 0; j < kl->getNumLocalParameters(); j++)
      {
        Parameter *lp = new Parameter(getLevel(), getVersion());
        (*lp) = *(kl->getLocalParameter(j));
        kl->addParameter(lp);
      }
    }
  }
}
Пример #2
0
void
Model::removeDuplicateTopLevelAnnotations()
{
  unsigned int i, n;
  this->removeDuplicateAnnotations();

  if (getNumFunctionDefinitions() > 0)
  {
    getListOfFunctionDefinitions()->removeDuplicateAnnotations();
    for (i = 0; i < getNumFunctionDefinitions(); i++)
    {
      getFunctionDefinition(i)->removeDuplicateAnnotations();
    }
  }
  if (getNumUnitDefinitions() > 0)
  {
    getListOfUnitDefinitions()->removeDuplicateAnnotations();
    for (i = 0; i < getNumUnitDefinitions(); i++)
    {
      getUnitDefinition(i)->removeDuplicateAnnotations();
      getUnitDefinition(i)->getListOfUnits()->removeDuplicateAnnotations();
      for (n = 0; n < getUnitDefinition(i)->getNumUnits(); n++)
      {
        getUnitDefinition(i)->getUnit(n)->removeDuplicateAnnotations();
      }
    }
  }
  if (getNumCompartmentTypes() > 0)
  {
    getListOfCompartmentTypes()->removeDuplicateAnnotations();
    for (i = 0; i < getNumCompartmentTypes(); i++)
    {
      getCompartmentType(i)->removeDuplicateAnnotations();
    }
  }
  if (getNumSpeciesTypes() > 0)
  {
    getListOfSpeciesTypes()->removeDuplicateAnnotations();
    for (i = 0; i < getNumSpeciesTypes(); i++)
    {
      getSpeciesType(i)->removeDuplicateAnnotations();
    }
  }
  if (getNumCompartments() > 0)
  {
    getListOfCompartments()->removeDuplicateAnnotations();
    for (i = 0; i < getNumCompartments(); i++)
    {
      getCompartment(i)->removeDuplicateAnnotations();
    }
  }
  if (getNumSpecies() > 0)
  {
    getListOfSpecies()->removeDuplicateAnnotations();
    for (i = 0; i < getNumSpecies(); i++)
    {
      getSpecies(i)->removeDuplicateAnnotations();
    }
  }
  if (getNumParameters() > 0)
  {
    getListOfParameters()->removeDuplicateAnnotations();
    for (i = 0; i < getNumParameters(); i++)
    {
      getParameter(i)->removeDuplicateAnnotations();
    }
  }
  if (getNumInitialAssignments() > 0)
  {
    getListOfInitialAssignments()->removeDuplicateAnnotations();
    for (i = 0; i < getNumInitialAssignments(); i++)
    {
      getInitialAssignment(i)->removeDuplicateAnnotations();
    }
  }
  if (getNumConstraints() > 0)
  {
    getListOfConstraints()->removeDuplicateAnnotations();
    for (i = 0; i < getNumConstraints(); i++)
    {
      getConstraint(i)->removeDuplicateAnnotations();
    }
  }
  if (getNumRules() > 0)
  {
    getListOfRules()->removeDuplicateAnnotations();
    for (i = 0; i < getNumRules(); i++)
    {
      getRule(i)->removeDuplicateAnnotations();
    }
  }
  if (getNumReactions() > 0)
  {
    getListOfReactions()->removeDuplicateAnnotations();
    for (i = 0; i < getNumReactions(); i++)
    {
      Reaction * r = getReaction(i);
      r->removeDuplicateAnnotations();
      if (r->getNumReactants() > 0)
      {
        r->getListOfReactants()->removeDuplicateAnnotations();
        for (n = 0; n < r->getNumReactants(); n++)
        {
          r->getReactant(n)->removeDuplicateAnnotations();
        }
      }
      if (r->getNumProducts() > 0)
      {
        r->getListOfProducts()->removeDuplicateAnnotations();
        for (n = 0; n < r->getNumProducts(); n++)
        {
          r->getProduct(n)->removeDuplicateAnnotations();
        }
      }
      if (r->getNumModifiers() > 0)
      {
        r->getListOfModifiers()->removeDuplicateAnnotations();
        for (n = 0; n < r->getNumModifiers(); n++)
        {
          r->getModifier(n)->removeDuplicateAnnotations();
        }
      }
      if (r->isSetKineticLaw())
      {
        r->getKineticLaw()->removeDuplicateAnnotations();
        if (r->getKineticLaw()->getNumParameters() > 0)
        {
          r->getKineticLaw()->getListOfParameters()
                            ->removeDuplicateAnnotations();
          for (n = 0; n < r->getKineticLaw()->getNumParameters(); n++)
          {
            r->getKineticLaw()->getParameter(n)->removeDuplicateAnnotations();
          }
        }
      }
    }
  }
  if (getNumEvents() > 0)
  {
    getListOfEvents()->removeDuplicateAnnotations();
    for (i = 0; i < getNumEvents(); i++)
    {
      getEvent(i)->removeDuplicateAnnotations();
      if (getEvent(i)->getNumEventAssignments() > 0)
      {
        getEvent(i)->getListOfEventAssignments()->removeDuplicateAnnotations();
        for (n = 0; n < getEvent(i)->getNumEventAssignments(); n++)
        {
          getEvent(i)->getEventAssignment(n)->removeDuplicateAnnotations();
        }
      }
    }
  }
}
Пример #3
0
void
Model::convertStoichiometryMath()
{
  unsigned int n, j;
  Reaction * r;
  SpeciesReference *sr;
  unsigned int idCount = 0;
  char newid[15];
  std::string id;

  for (n = 0; n < getNumReactions(); n++)
  {
    r = getReaction(n);
    for (j = 0; j < r->getNumReactants(); j++)
    {
      sr = r->getReactant(j);
      if (sr->isSetStoichiometryMath())
      {
        if (!sr->isSetId())
        {
          sprintf(newid, "generatedId_%u", idCount);
          id.assign(newid);
          sr->setId(id);
          idCount++;
        }
        else
        {
          id = sr->getId();
        }
        sr->setConstant(false);

        AssignmentRule * ar = createAssignmentRule();
        ar->setVariable(id);
        if (sr->getStoichiometryMath()->isSetMath())
        {
          ar->setMath(sr->getStoichiometryMath()->getMath());
        }
      }
    }
    for (j = 0; j < r->getNumProducts(); j++)
    {
      sr = r->getProduct(j);
      if (sr->isSetStoichiometryMath())
      {
        if (!sr->isSetId())
        {
          sprintf(newid, "generatedId_%u", idCount);
          id.assign(newid);
          sr->setId(id);
          idCount++;
        }
        else
        {
          id = sr->getId();
        }

        sr->setConstant(false);
        AssignmentRule * ar = createAssignmentRule();
        ar->setVariable(id);
        if (sr->getStoichiometryMath()->isSetMath())
        {
          ar->setMath(sr->getStoichiometryMath()->getMath());
        }
      }
    }
  }
}
Пример #4
0
void
Model::removeSBOTermsNotInL2V2(bool strict)
{
  unsigned int n, i;

  if (strict == true)
  {
    for (n = 0; n < getNumUnitDefinitions(); n++)
    {
      getUnitDefinition(n)->unsetSBOTerm();
      for (i = 0; i < getUnitDefinition(n)->getNumUnits(); i++)
      {
        getUnitDefinition(n)->getUnit(i)->unsetSBOTerm();
      }
    }

    for (n = 0; n < getNumCompartments(); n++)
    {
      getCompartment(n)->unsetSBOTerm();
    }

    for (n = 0; n < getNumSpecies(); n++)
    {
      getSpecies(n)->unsetSBOTerm();
    }

    for (n = 0; n < getNumCompartmentTypes(); n++)
    {
      getCompartmentType(n)->unsetSBOTerm();
    }

    for (n = 0; n < getNumSpeciesTypes(); n++)
    {
      getSpeciesType(n)->unsetSBOTerm();
    }


    for (n = 0; n < getNumReactions(); n++)
    {
      for (i = 0; i < getReaction(n)->getNumReactants(); i++)
      {
        if (getReaction(n)->getReactant(i)->isSetStoichiometryMath())
        {
          getReaction(n)->getReactant(i)->getStoichiometryMath()->unsetSBOTerm();
        }
      }
      for (i = 0; i < getReaction(n)->getNumProducts(); i++)
      {
        if (getReaction(n)->getProduct(i)->isSetStoichiometryMath())
        {
          getReaction(n)->getProduct(i)->getStoichiometryMath()->unsetSBOTerm();
        }
      }
    }

    for (n = 0; n < getNumEvents(); n++)
    {
      if (getEvent(n)->isSetTrigger())
      {
        getEvent(n)->getTrigger()->unsetSBOTerm();
      }
      if (getEvent(n)->isSetDelay())
      {
        getEvent(n)->getDelay()->unsetSBOTerm();
      }
    }
  }
}
Пример #5
0
void
Model::removeSBOTerms(bool strict)
{
  unsigned int n, i;

  if (strict == true)
  {
    unsetSBOTerm();
    
    for (n = 0; n < getNumUnitDefinitions(); n++)
    {
      getUnitDefinition(n)->unsetSBOTerm();
      for (i = 0; i < getUnitDefinition(n)->getNumUnits(); i++)
      {
        getUnitDefinition(n)->getUnit(i)->unsetSBOTerm();
      }
    }

    for (n = 0; n < getNumCompartments(); n++)
    {
      getCompartment(n)->unsetSBOTerm();
    }

    for (n = 0; n < getNumSpecies(); n++)
    {
      getSpecies(n)->unsetSBOTerm();
    }

    for (n = 0; n < getNumParameters(); n++)
    {
      getParameter(n)->unsetSBOTerm();
    }

    for (n = 0; n < getNumRules(); n++)
    {
      getRule(n)->unsetSBOTerm();
    }

    for (n = 0; n < getNumReactions(); n++)
    {
      getReaction(n)->unsetSBOTerm();
      for (i = 0; i < getReaction(n)->getNumReactants(); i++)
      {
        getReaction(n)->getReactant(i)->unsetSBOTerm();
        if (getReaction(n)->getReactant(i)->isSetStoichiometryMath())
        {
          getReaction(n)->getReactant(i)->getStoichiometryMath()->unsetSBOTerm();
        }
      }
      for (i = 0; i < getReaction(n)->getNumProducts(); i++)
      {
        getReaction(n)->getProduct(i)->unsetSBOTerm();
        if (getReaction(n)->getProduct(i)->isSetStoichiometryMath())
        {
          getReaction(n)->getProduct(i)->getStoichiometryMath()->unsetSBOTerm();
        }
      }
      for (i = 0; i < getReaction(n)->getNumModifiers(); i++)
      {
        getReaction(n)->getModifier(i)->unsetSBOTerm();
      }
      if (getReaction(n)->isSetKineticLaw())
      {
        getReaction(n)->getKineticLaw()->unsetSBOTerm();
      }
    }

    for (n = 0; n < getNumFunctionDefinitions(); n++)
    {
      getFunctionDefinition(n)->unsetSBOTerm();
    }

    for (n = 0; n < getNumEvents(); n++)
    {
      getEvent(n)->unsetSBOTerm();
      for (i = 0; i < getEvent(n)->getNumEventAssignments(); i++)
      {
        getEvent(n)->getEventAssignment(i)->unsetSBOTerm();
      }
      if (getEvent(n)->isSetTrigger())
      {
        getEvent(n)->getTrigger()->unsetSBOTerm();
      }
      if (getEvent(n)->isSetDelay())
      {
        getEvent(n)->getDelay()->unsetSBOTerm();
      }
    }
  }
}
Пример #6
0
void
Model::dealWithStoichiometry()
{
  unsigned int idCount = 0;
  for (unsigned int i = 0; i < getNumReactions(); i++)
  {
    Reaction *r = getReaction(i);
    unsigned int j;

    for (j = 0; j < r->getNumReactants(); j++)
    {
      SpeciesReference *sr = r->getReactant(j);
      if (sr->isSetStoichiometry() == false)
      {
        if (sr->isSetId() == false)
        {
          createNoValueStoichMath(*this, *sr, idCount);
          idCount++;
        }
        else
        {
          // id is set it could be used by initialAssignment
          // used by rule
          // not used
          if (getInitialAssignment(sr->getId()) != NULL)
          {
            useStoichMath(*this, *sr, false);
          }
          else if (getRule(sr->getId()) != NULL)
          {
            //assignmentRule
            if (getRule(sr->getId())->getTypeCode() == SBML_ASSIGNMENT_RULE)
            {  
              useStoichMath(*this, *sr, true);
            }
            else if (getRule(sr->getId())->getTypeCode() == SBML_RATE_RULE)
            {
              createParameterAsRateRule(*this, *sr, *(getRule(sr->getId())), idCount);
              idCount++;
            }
          }
          else
          {
            createNoValueStoichMath(*this, *sr, idCount);
            idCount++;
          }
        }
      }
      else
      {
        // stoichiometry is set
        if (sr->isSetId())
        {
          // id is set it could be used by initialAssignment
          // used by rule
          // not used
          if (getInitialAssignment(sr->getId()) != NULL)
          {
            useStoichMath(*this, *sr, false);
          }
          else if (getRule(sr->getId()) != NULL)
          {
            //assignmentRule
            if (getRule(sr->getId())->getTypeCode() == SBML_ASSIGNMENT_RULE)
            {            
              useStoichMath(*this, *sr, true);
            }
            else if (getRule(sr->getId())->getTypeCode() == SBML_RATE_RULE)
            {
              createParameterAsRateRule(*this, *sr, *(getRule(sr->getId())), idCount);
              idCount++;
            }
          }
        }
        // no id set - do not need to do anything
      }
    }
    for (j = 0; j < r->getNumProducts(); j++)
    {
      SpeciesReference *sr = r->getProduct(j);
      if (sr->isSetStoichiometry() == false)
      {
        if (sr->isSetId() == false)
        {
          createNoValueStoichMath(*this, *sr, idCount);
          idCount++;
        }
        else
        {
          // id is set it could be used by initialAssignment
          // used by rule
          // not used
          if (getInitialAssignment(sr->getId()) != NULL)
          {
            useStoichMath(*this, *sr, false);
          }
          else if (getRule(sr->getId()) != NULL)
          {
            //assignmentRule
            if (getRule(sr->getId())->getTypeCode() == SBML_ASSIGNMENT_RULE)
            {  
              useStoichMath(*this, *sr, true);
            }
            else if (getRule(sr->getId())->getTypeCode() == SBML_RATE_RULE)
            {
              createParameterAsRateRule(*this, *sr, *(getRule(sr->getId())), idCount);
              idCount++;
            }
          }
          else
          {
            createNoValueStoichMath(*this, *sr, idCount);
            idCount++;
          }
        }
      }
      else
      {
        // stoichiometry is set
        if (sr->isSetId())
        {
          // id is set it could be used by initialAssignment
          // used by rule
          // not used
          if (getInitialAssignment(sr->getId()) != NULL)
          {
            useStoichMath(*this, *sr, false);
          }
          else if (getRule(sr->getId()) != NULL)
          {
            //assignmentRule
            if (getRule(sr->getId())->getTypeCode() == SBML_ASSIGNMENT_RULE)
            {            
              useStoichMath(*this, *sr, true);
            }
            else if (getRule(sr->getId())->getTypeCode() == SBML_RATE_RULE)
            {
              createParameterAsRateRule(*this, *sr, *(getRule(sr->getId())), idCount);
              idCount++;
            }
          }
        }
        // no id set - do not need to do anything
      }
    }
  }
}
Пример #7
0
void
Model::assignRequiredValues()
{
  // when converting to L3 some attributes which have default values in L1/L2
  // but are required in L3 are not present or set
  unsigned int i, n;

  if (getNumUnitDefinitions() > 0)
  {
    for (i = 0; i < getNumUnitDefinitions(); i++)
    {
      for (n = 0; n < getUnitDefinition(i)->getNumUnits(); n++)
      {
        Unit *u = getUnitDefinition(i)->getUnit(n);
        if (!u->isSetExponent())
          u->setExponent(1.0);
        if (!u->isSetScale())
          u->setScale(0);
        if (!u->isSetMultiplier())
          u->setMultiplier(1.0);
      }
    }
  }
  
  if (getNumCompartments() > 0)
  {
    for (i = 0; i < getNumCompartments(); i++)
    {
      Compartment *c = getCompartment(i);
      c->setConstant(c->getConstant());
    }
  }
  if (getNumSpecies() > 0)
  {
    for (i = 0; i < getNumSpecies(); i++)
    {
      Species * s = getSpecies(i);
      s->setBoundaryCondition(s->getBoundaryCondition());
      s->setHasOnlySubstanceUnits(s->getHasOnlySubstanceUnits());
      s->setConstant(s->getConstant());
    }
  }
  if (getNumParameters() > 0)
  {
    for (i = 0; i < getNumParameters(); i++)
    {
      Parameter * p = getParameter(i);
      p->setConstant(p->getConstant());
    }
  }
  if (getNumReactions() > 0)
  {
    for (i = 0; i < getNumReactions(); i++)
    {
      Reaction * r = getReaction(i);
      r->setFast(r->getFast());
      r->setReversible(r->getReversible());
      if (r->getNumReactants() > 0)
      {
        for (n = 0; n < r->getNumReactants(); n++)
        {
          SpeciesReference *sr = r->getReactant(n);
          if (sr->isSetStoichiometryMath())
          {
            sr->setConstant(false);
          }
          else
          {
            sr->setConstant(true);
          }
        }
      }
      if (r->getNumProducts() > 0)
      {
        for (n = 0; n < r->getNumProducts(); n++)
        {
          SpeciesReference *sr = r->getProduct(n);
          if (sr->isSetStoichiometryMath())
          {
            sr->setConstant(false);
          }
          else
          {
            sr->setConstant(true);
          }
        }
      }
    }
  }
  if (getNumEvents() > 0)
  {
    for (i = 0; i < getNumEvents(); i++)
    {
      Event * e = getEvent(i);
      e->setUseValuesFromTriggerTime(e->getUseValuesFromTriggerTime());

      if (e->isSetTrigger())
      {
        Trigger *t = e->getTrigger();
        t->setPersistent(true);
        t->setInitialValue(true);
      }
    }
  }

}
Пример #8
0
static int callBackWithLogKeeping(int iter, int popSz, GApopulation pop, double * fitnessArray, int *** parentsArray)
{
	unsigned long long * seeds;
	double f;
	int i,j,k,*parents, num = 10*popSz, max = 0, stop = 0;
	int * temp = 0, * ids = 0;
	GAindividual * p;
	//save
	int each_fitness = PRINT_EACH_FITNESS,
		each_script = PRINT_EACH_SCRIPT,
		each_size = PRINT_EACH_SIZE,
		each_best_lineage = PRINT_EACH_BEST_LINEAGE,
		each_all_fitness = PRINT_EACH_ALL_FITNESS,
		each_all_lineage = PRINT_EACH_ALL_LINEAGE;

	if (USER_CALLBACK_FNC)
		stop = USER_CALLBACK_FNC(iter,popSz,pop,fitnessArray, parentsArray);

	if (!stop)
		stop = (iter == _MAX_ITER);

	if (stop)
	{
		//cheat
		PRINT_EACH_FITNESS = PRINT_FINAL_FITNESS;
		PRINT_EACH_SCRIPT = PRINT_FINAL_SCRIPT;
		PRINT_EACH_SIZE = PRINT_FINAL_SIZE;
		PRINT_EACH_BEST_LINEAGE = PRINT_FINAL_BEST_LINEAGE;
		PRINT_EACH_ALL_FITNESS = PRINT_FINAL_ALL_FITNESS;
		PRINT_EACH_ALL_LINEAGE = PRINT_FINAL_ALL_LINEAGE;

		//printf("\n========final results=======\n");
		fprintf(LOGFILE,"\n========final results=======\n");

		if (LOGFILE && PRINT_SEEDS)
		{
			seeds = getMTseeds();
			fprintf(LOGFILE,"random number generator seeds: %llf,%llf,%llf,%llf\n",seeds[0],seeds[1],seeds[2],seeds[3]);
		}
	}

	if (iter == 0) //header
	{
		printf("gen");
		fprintf(LOGFILE,"gen");
		if (PRINT_EACH_FITNESS && !PRINT_EACH_ALL_FITNESS)
		{
			printf("\tfitness ");
			fprintf(LOGFILE,"\tfitness ");
		}

		if (PRINT_EACH_ALL_FITNESS)
		{
			for (i=0; i < popSz; ++i)
			{
				//printf("\tfitness_%i",i);
				fprintf(LOGFILE,"\tfitness_%i",i);
			}
		}

		if (PRINT_EACH_SIZE)
		{
			printf("\tspecies\treactions");
			fprintf(LOGFILE,"\tspecies\treactions");
		}

		if (TRACK_NETWORK_PARENTS && (PRINT_EACH_BEST_LINEAGE || PRINT_EACH_ALL_LINEAGE))
		{
			//printf("\tparents");
			fprintf(LOGFILE,"\tparents");
		}

		printf("\n");
		fprintf(LOGFILE,"\n");

		printf("---");
		fprintf(LOGFILE,"---");

		if (PRINT_EACH_FITNESS && !PRINT_EACH_ALL_FITNESS)
		{
			printf("\t------- ");
			fprintf(LOGFILE,"\t------- ");
		}

		if (PRINT_EACH_ALL_FITNESS)
		{
			for (i=0; i < popSz; ++i)
			{
				//printf("\t----------",i);
				fprintf(LOGFILE,"\t -------- ",i);
			}
		}

		if (PRINT_EACH_SIZE)
		{
			printf("\t-------\t---------");
			fprintf(LOGFILE,"\t-------\t---------");
		}

		if (TRACK_NETWORK_PARENTS && (PRINT_EACH_BEST_LINEAGE || PRINT_EACH_ALL_LINEAGE))
		{
			//printf("\t-------");
			fprintf(LOGFILE,"\t-------");
		}

		printf("\n");
		fprintf(LOGFILE,"\n");
	}

	if (TRACK_NETWORK_PARENTS && (PRINT_EACH_BEST_LINEAGE || PRINT_EACH_ALL_LINEAGE))
	{
		ids = (int*)malloc(num * sizeof(int));

		for (i=0; i < num; ++i)
			ids[i] = 0;

		for (i=0; i < popSz; ++i)
		{
			p = pop[i];

			if (!p) continue;

			parents = GAgetOriginalParents(i,iter,parentsArray);
			if (parents)
			{
				for (j=0; parents[j] > 0; ++j)
				{
					if (parents[j] >= max)
						max = parents[j];

					if (parents[j] >= num)
					{
						temp = ids;
						ids = (int*)malloc( num * 2 * sizeof(int) );

						for (k=0; k < num; ++k)
							ids[k] = temp[k];

						num *= 2;

						for (; k < num; ++k)
							ids[k] = 0;

						free(temp);
					}

					ids[ parents[j] ] += 1;
				}
			}
			else
			{
			}

			if (PRINT_EACH_BEST_LINEAGE && !PRINT_EACH_ALL_LINEAGE)
				break;
		}
	}

	printf("%i",iter);
	fprintf(LOGFILE,"%i",iter);
	if (PRINT_EACH_FITNESS && !PRINT_EACH_ALL_FITNESS)
	{
		f = fitnessArray[0];
		printf("\t%lf",f);
		fprintf(LOGFILE,"\t%lf",f);
	}

	if (PRINT_EACH_ALL_FITNESS)
	{
		for (i=0; i < popSz; ++i)
		{
			f = fitnessArray[i];
			//printf("\t%lf",f);
			fprintf(LOGFILE,"\t%lf",f);
		}
	}

	if (PRINT_EACH_SIZE)
	{
		printf("\t%i\t%i",getNumSpecies(pop[0]),getNumReactions(pop[0]));
		fprintf(LOGFILE,"\t%i\t%i",getNumSpecies(pop[0]),getNumReactions(pop[0]));
	}

	if (TRACK_NETWORK_PARENTS && (PRINT_EACH_BEST_LINEAGE || PRINT_EACH_ALL_LINEAGE))
	{
		for (i=0; i < max; ++i)
		{
			//printf("\t%i",ids[i]);
			fprintf(LOGFILE,"\t%i",ids[i]);
		}
	}

	if (PRINT_EACH_SCRIPT)
	{
		//printf("\n========script=======\n");
		fprintf(LOGFILE,"\n========script=======\n");

		//printNetwork(stdout,pop[0]);
		printNetwork(LOGFILE,pop[0]);

		//printf("\n=====================\n");
		fprintf(LOGFILE,"\n=====================\n");
	}

	printf("\n");
	fprintf(LOGFILE,"\n");

	if (ids && (num > 0))
		free(ids);

	if (iter == _MAX_ITER)
	{
		//restore
		PRINT_EACH_FITNESS = each_fitness;
		PRINT_EACH_SCRIPT = each_script;
		PRINT_EACH_SIZE = each_size;
		PRINT_EACH_BEST_LINEAGE = each_best_lineage;
		PRINT_EACH_ALL_FITNESS = each_all_fitness;
		PRINT_EACH_ALL_LINEAGE = each_all_lineage;
	}

	return stop;
}