[Avida-SVN] r1602 - in branches/uml/source: actions main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Thu May 24 20:10:57 PDT 2007
Author: hjg
Date: 2007-05-24 23:10:56 -0400 (Thu, 24 May 2007)
New Revision: 1602
Modified:
branches/uml/source/actions/PrintActions.cc
branches/uml/source/main/cBirthChamber.cc
branches/uml/source/main/cOrganism.cc
branches/uml/source/main/cOrganism.h
branches/uml/source/main/cTaskLib.cc
branches/uml/source/main/cUMLModel.cc
branches/uml/source/main/cUMLModel.h
branches/uml/source/main/cUMLStateDiagram.cc
Log:
Added support for stats collecting about the UML model.
Modified: branches/uml/source/actions/PrintActions.cc
===================================================================
--- branches/uml/source/actions/PrintActions.cc 2007-05-24 12:20:08 UTC (rev 1601)
+++ branches/uml/source/actions/PrintActions.cc 2007-05-25 03:10:56 UTC (rev 1602)
@@ -1885,6 +1885,8 @@
action_lib->Register<cActionPrintInstructionData>("print_instruction_data");
action_lib->Register<cActionPrintGenotypeMap>("print_genotype_map");
action_lib->Register<cActionPrintMarketData>("print_market_data");
+ action_lib->Register<cActionPrintUMLData>("PrintUMLData");
+
action_lib->Register<cActionPrintPhenotypeData>("print_number_phenotypes");
action_lib->Register<cActionPrintPhenotypeStatus>("print_phenotype_status");
Modified: branches/uml/source/main/cBirthChamber.cc
===================================================================
--- branches/uml/source/main/cBirthChamber.cc 2007-05-24 12:20:08 UTC (rev 1601)
+++ branches/uml/source/main/cBirthChamber.cc 2007-05-25 03:10:56 UTC (rev 1602)
@@ -165,6 +165,8 @@
child_genotype->IncDeferAdjust();
+ // FOR UML branch - hjg
+ child_array[0]->setParentModel(parent.getUMLModel());
return true;
}
Modified: branches/uml/source/main/cOrganism.cc
===================================================================
--- branches/uml/source/main/cOrganism.cc 2007-05-24 12:20:08 UTC (rev 1601)
+++ branches/uml/source/main/cOrganism.cc 2007-05-25 03:10:56 UTC (rev 1602)
@@ -633,12 +633,13 @@
}
if (clear_input) m_input_buf.Clear();
- /*
+/*
m_world->GetStats().addState(states.size());
m_world->GetStats().addTrans(transitions.size());
m_world->GetStats().addTransLabel(transition_labels.size());
- */
+*/
+
}
cUMLModel* cOrganism::getUMLModel()
Modified: branches/uml/source/main/cOrganism.h
===================================================================
--- branches/uml/source/main/cOrganism.h 2007-05-24 12:20:08 UTC (rev 1601)
+++ branches/uml/source/main/cOrganism.h 2007-05-25 03:10:56 UTC (rev 1602)
@@ -149,6 +149,7 @@
int m_guard_index;
int m_action_index;
cUMLModel m_model; // Used when not running as deme
+ cUMLModel* m_parent_model; // Used when not running as deme
class cNetSupport
{
@@ -309,12 +310,15 @@
// UML
void modelCheck(cAvidaContext& ctx);
cUMLModel* getUMLModel();
+ cUMLModel* getParentUMLModel() { return m_parent_model; }
int getStateDiagramIndex() { return m_state_diag; }
// bool lastStateDiagram () { m_state_diag = getUMLModel()->getStateDiagramSize(); }
// bool firstStateDiagram() { m_state_diag = 0; }
bool currTrans (int, int, int, int, int, int);
cUMLStateDiagram* getStateDiagram();
void printStats();
+ void setParentModel(cUMLModel* m) { m_parent_model = m; }
+
// The jump functions jump the index of the various vectors either forward (+ int) or backwards (- int)
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2007-05-24 12:20:08 UTC (rev 1601)
+++ branches/uml/source/main/cTaskLib.cc 2007-05-25 03:10:56 UTC (rev 1602)
@@ -2897,5 +2897,16 @@
}
double cTaskLib::Task_ModEval(cTaskContext& ctx) const {
- return (ctx.organism->getUMLModel()->evaluateModel(ctx.organism->GetID(), m_world));
+ double bonus = 0.0;
+ cUMLModel* par = ctx.organism->getParentUMLModel();
+ cUMLModel* self = ctx.organism->getUMLModel();
+
+ if (self->getXMI() != par->getXMI()) {
+ bonus = self->evaluateModel(ctx.organism->GetID(), m_world);
+ } else {
+ // get bonus of other model...
+
+ }
+
+ return bonus;
}
Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc 2007-05-24 12:20:08 UTC (rev 1601)
+++ branches/uml/source/main/cUMLModel.cc 2007-05-25 03:10:56 UTC (rev 1602)
@@ -164,9 +164,12 @@
int s0_nt = getStateDiagram(0)->numTrans();
int s1_nt = getStateDiagram(1)->numTrans();
-
+
cUMLStateDiagram* temp_sense = getStateDiagram(0);
cUMLStateDiagram* soft_sense = getStateDiagram(1);
+
+ world->GetStats().addState(temp_sense->numStates() + soft_sense->numStates());
+ world->GetStats().addTrans(s0_nt + s1_nt);
// Check if the model meets the sequence diagram
@@ -177,7 +180,7 @@
// if (bonus >= 5.0) {
if (temp_sense->findTrans(-1, -1, -1, -1, 1)) {
self_bonus["hydra_attempt"] = 1;
- mod_bonus = formalizeModel();
+ mod_bonus = formalizeModel(world);
self_bonus["hydra_pass"] = mod_bonus;
bonus += mod_bonus;
}
@@ -185,7 +188,7 @@
// Check if the model meets the properties.
if (mod_bonus > 0.0) {
- self_bonus["spin_attemp"] = 1;
+ self_bonus["spin_attempt"] = 1;
mod_bonus += propertyN1(id, world);
self_bonus["spin_pass"] = mod_bonus;
bonus += mod_bonus;
@@ -330,7 +333,7 @@
return x;
}
-double cUMLModel::formalizeModel()
+double cUMLModel::formalizeModel(cWorld* world)
{
printXMI();
std::string temp = xmi;
@@ -343,7 +346,7 @@
}*/
-// m_world->GetStats().HydraAttempt();
+ world->GetStats().HydraAttempt();
double bonus = 0.0;
unsigned int status_total = 0;
@@ -413,7 +416,7 @@
} else {
// ctx->task_failed = ctx->task_failed && 1;
// ctx.task_success_complete += 1;
-//// m_world->GetStats().HydraPassed();
+ world->GetStats().HydraPassed();
// organism->setBonusInfo("hydra", 1.0);
return 1;
}
@@ -422,12 +425,12 @@
double cUMLModel::checkProperty(const std::string& neverclaimFile, int id, cWorld* world) const {
-// m_world->GetStats().SpinAttempt();
+ world->GetStats().SpinAttempt();
double status=0;
std::string cmd = "cat " + neverclaimFile + " >> tmp.pr && ./spin -a tmp.pr &> /dev/null";
if(system(cmd.c_str())!=0) return 0;
-// m_world->GetStats().SpinPassed();
-// m_world->GetStats().PanAttempt();
+ world->GetStats().SpinPassed();
+ world->GetStats().PanAttempt();
if(system("/usr/bin/gcc -DMEMLIM=512 pan.c -o pan &> /dev/null")!=0) return 0;
if(system("./pan -a &> ./pan.out")!=0) return 0;
@@ -441,7 +444,7 @@
if(system("cat pan.out | perl -e 'while(<STDIN>) { if(/unreached/) {exit(1);}}'")!=0) return 1;
-// m_world->GetStats().PanPassed();
+ world->GetStats().PanPassed();
return 3;
}
Modified: branches/uml/source/main/cUMLModel.h
===================================================================
--- branches/uml/source/main/cUMLModel.h 2007-05-24 12:20:08 UTC (rev 1601)
+++ branches/uml/source/main/cUMLModel.h 2007-05-25 03:10:56 UTC (rev 1602)
@@ -22,7 +22,7 @@
std::string getXMI(); // get the XMI version of the model
void printXMI();
void resetUMLModel();
- double formalizeModel(); // formalize the model using Hydra
+ double formalizeModel(cWorld*); // formalize the model using Hydra
double checkProperty(const std::string& neverclaimFile, int, cWorld*) const; // check for property satisfaction using Spin
double propertyN1(int, cWorld*) const; // check for property N1
Modified: branches/uml/source/main/cUMLStateDiagram.cc
===================================================================
--- branches/uml/source/main/cUMLStateDiagram.cc 2007-05-24 12:20:08 UTC (rev 1601)
+++ branches/uml/source/main/cUMLStateDiagram.cc 2007-05-25 03:10:56 UTC (rev 1602)
@@ -431,14 +431,14 @@
for (; s_count < numStates(); ++s_count) {
// only print if this state has an incoming edge.
- if ((states[s_count]).num_incoming > 0) {
+// if ((states[s_count]).num_incoming > 0) {
temp = "s" + StringifyAnInt(s_count);
xmi+="<UML:CompositeState xmi.id=\"";
xmi+=temp;
xmi+= "\" isConcurrent=\"false\" name=\"";
xmi+= temp;
xmi+= "\" isSpecification=\"false\"/>\n";
- }
+// }
}
// end the set of states....
More information about the Avida-cvs
mailing list