[Avida-SVN] r2097 - in branches/uml/source: cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Tue Sep 18 11:59:16 PDT 2007
Author: hjg
Date: 2007-09-18 14:59:15 -0400 (Tue, 18 Sep 2007)
New Revision: 2097
Modified:
branches/uml/source/cpu/cHardwareCPU.cc
branches/uml/source/cpu/cHardwareCPU.h
branches/uml/source/main/cTaskLib.cc
branches/uml/source/main/cTaskLib.h
branches/uml/source/main/cUMLStateDiagram.cc
Log:
Created tasks that reward an organism for modifying state diagrams such that they now violate a property. These tasks are designed to be used to produce software faults.
Modified: branches/uml/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.cc 2007-09-17 18:45:15 UTC (rev 2096)
+++ branches/uml/source/cpu/cHardwareCPU.cc 2007-09-18 18:59:15 UTC (rev 2097)
@@ -441,33 +441,33 @@
tInstLibEntry<tMethod>("s-dest-11", &cHardwareCPU::Inst_DestState11, false,
"Change the destination to state 11"),
tInstLibEntry<tMethod>("s-dest-12", &cHardwareCPU::Inst_DestState12, false,
- "Change the destination to state 12"),
-/* tInstLibEntry<tMethod>("trans-0", &cHardwareCPU::Inst_TransLab0, false,
- "Change to transition label 0"),
- tInstLibEntry<tMethod>("trans-1", &cHardwareCPU::Inst_TransLab1, false,
- "Change to transition label 1"),
- tInstLibEntry<tMethod>("trans-2", &cHardwareCPU::Inst_TransLab2, false,
- "Change to transition label 2"),
- tInstLibEntry<tMethod>("trans-3", &cHardwareCPU::Inst_TransLab3, false,
- "Change to transition label 3"),
- tInstLibEntry<tMethod>("trans-4", &cHardwareCPU::Inst_TransLab4, false,
- "Change to transition label 4"),
- tInstLibEntry<tMethod>("trans-5", &cHardwareCPU::Inst_TransLab5, false,
- "Change to transition label 5"),
- tInstLibEntry<tMethod>("trans-6", &cHardwareCPU::Inst_TransLab6, false,
- "Change to transition label 6"),
- tInstLibEntry<tMethod>("trans-7", &cHardwareCPU::Inst_TransLab7, false,
- "Change to transition label 7"),
- tInstLibEntry<tMethod>("trans-8", &cHardwareCPU::Inst_TransLab8, false,
- "Change to transition label 8"),
- tInstLibEntry<tMethod>("trans-9", &cHardwareCPU::Inst_TransLab9, false,
- "Change to transition label 9"),
- tInstLibEntry<tMethod>("trans-10", &cHardwareCPU::Inst_TransLab10, false,
- "Change to transition label 10"),
- tInstLibEntry<tMethod>("trans-11", &cHardwareCPU::Inst_TransLab11, false,
- "Change to transition label 11"),
-*/
-
+ "Change the destination to state 12"),
+ tInstLibEntry<tMethod>("rm-t-0", &cHardwareCPU::Inst_RemoveTrans0, false,
+ "Remove transition 0"),
+ tInstLibEntry<tMethod>("rm-t-1", &cHardwareCPU::Inst_RemoveTrans1, false,
+ "Remove transition 1"),
+ tInstLibEntry<tMethod>("rm-t-2", &cHardwareCPU::Inst_RemoveTrans2, false,
+ "Remove transition 2"),
+ tInstLibEntry<tMethod>("rm-t-3", &cHardwareCPU::Inst_RemoveTrans3, false,
+ "Remove transition 3"),
+ tInstLibEntry<tMethod>("rm-t-4", &cHardwareCPU::Inst_RemoveTrans4, false,
+ "Remove transition 4"),
+ tInstLibEntry<tMethod>("rm-t-5", &cHardwareCPU::Inst_RemoveTrans5, false,
+ "Remove transition 5"),
+ tInstLibEntry<tMethod>("rm-t-6", &cHardwareCPU::Inst_RemoveTrans6, false,
+ "Remove transition 6"),
+ tInstLibEntry<tMethod>("rm-t-7", &cHardwareCPU::Inst_RemoveTrans7, false,
+ "Remove transition 7"),
+ tInstLibEntry<tMethod>("rm-t-8", &cHardwareCPU::Inst_RemoveTrans8, false,
+ "Remove transition 8"),
+ tInstLibEntry<tMethod>("rm-t-9", &cHardwareCPU::Inst_RemoveTrans9, false,
+ "Remove transition 9"),
+ tInstLibEntry<tMethod>("rm-t-10", &cHardwareCPU::Inst_RemoveTrans10, false,
+ "Remove transition 10"),
+ tInstLibEntry<tMethod>("rm-t-11", &cHardwareCPU::Inst_RemoveTrans11, false,
+ "Remove transition 11"),
+ tInstLibEntry<tMethod>("rm-t-12", &cHardwareCPU::Inst_RemoveTrans12, false,
+ "Remove transition 12"),
tInstLibEntry<tMethod>("trig-0", &cHardwareCPU::Inst_Trigger0, false,
"Change to trigger 0"),
tInstLibEntry<tMethod>("trig-1", &cHardwareCPU::Inst_Trigger1, false,
@@ -5045,3 +5045,45 @@
bool cHardwareCPU::Inst_Action13(cAvidaContext& ctx)
{ return (organism->getStateDiagram()->absoluteJumpAction(13)); }
+
+bool cHardwareCPU::Inst_RemoveTrans0(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(0)); }
+
+bool cHardwareCPU::Inst_RemoveTrans1(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(1)); }
+
+bool cHardwareCPU::Inst_RemoveTrans2(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(2)); }
+
+bool cHardwareCPU::Inst_RemoveTrans3(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(3)); }
+
+bool cHardwareCPU::Inst_RemoveTrans4(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(4)); }
+
+bool cHardwareCPU::Inst_RemoveTrans5(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(5)); }
+
+bool cHardwareCPU::Inst_RemoveTrans6(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(6)); }
+
+bool cHardwareCPU::Inst_RemoveTrans7(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(7)); }
+
+bool cHardwareCPU::Inst_RemoveTrans8(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(8)); }
+
+bool cHardwareCPU::Inst_RemoveTrans9(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(9)); }
+
+bool cHardwareCPU::Inst_RemoveTrans10(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(10)); }
+
+bool cHardwareCPU::Inst_RemoveTrans11(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(11)); }
+
+bool cHardwareCPU::Inst_RemoveTrans12(cAvidaContext& ctx)
+{ return (organism->getStateDiagram()->removeTransition(12)); }
+
+
+
Modified: branches/uml/source/cpu/cHardwareCPU.h
===================================================================
--- branches/uml/source/cpu/cHardwareCPU.h 2007-09-17 18:45:15 UTC (rev 2096)
+++ branches/uml/source/cpu/cHardwareCPU.h 2007-09-18 18:59:15 UTC (rev 2097)
@@ -605,6 +605,20 @@
bool Inst_TransLab9(cAvidaContext& ctx);
bool Inst_TransLab10(cAvidaContext& ctx);
bool Inst_TransLab11(cAvidaContext& ctx);*/
+
+ bool Inst_RemoveTrans0(cAvidaContext& ctx);
+ bool Inst_RemoveTrans1(cAvidaContext& ctx);
+ bool Inst_RemoveTrans2(cAvidaContext& ctx);
+ bool Inst_RemoveTrans3(cAvidaContext& ctx);
+ bool Inst_RemoveTrans4(cAvidaContext& ctx);
+ bool Inst_RemoveTrans5(cAvidaContext& ctx);
+ bool Inst_RemoveTrans6(cAvidaContext& ctx);
+ bool Inst_RemoveTrans7(cAvidaContext& ctx);
+ bool Inst_RemoveTrans8(cAvidaContext& ctx);
+ bool Inst_RemoveTrans9(cAvidaContext& ctx);
+ bool Inst_RemoveTrans10(cAvidaContext& ctx);
+ bool Inst_RemoveTrans11(cAvidaContext& ctx);
+ bool Inst_RemoveTrans12(cAvidaContext& ctx);
bool Inst_Trigger0(cAvidaContext& ctx);
bool Inst_Trigger1(cAvidaContext& ctx);
Modified: branches/uml/source/main/cTaskLib.cc
===================================================================
--- branches/uml/source/main/cTaskLib.cc 2007-09-17 18:45:15 UTC (rev 2096)
+++ branches/uml/source/main/cTaskLib.cc 2007-09-18 18:59:15 UTC (rev 2097)
@@ -431,6 +431,11 @@
NewTask(name, "Non-determinism", &cTaskLib::Task_Nondeterminism);
else if (name == "export-xmi")
NewTask(name, "Export XMI", &cTaskLib::Task_ExportXMI);
+ else if (name == "not-n1")
+ NewTask(name, "Violate property 1", &cTaskLib::Task_ViolateN1);
+ else if (name == "not-n2")
+ NewTask(name, "Violate property 2", &cTaskLib::Task_ViolateN2);
+
/* else if (name == "mult_trans") //
NewTask(name, "Successfully completed multiple transitions", &cTaskLib::Task_MultTrans);*/
@@ -3112,9 +3117,7 @@
// if(system("cat pan.out | perl -e 'while(<STDIN>) { if(/unreached/) {exit(1);}}'")!=0) return 0.2;
-// Commented out to remove overhead...
std::ostringstream strstrm;
-// strstrm << "cp " << file_name << " " << neverclaimFile << "." << m_world->GetStats().GetUpdate() << "." << ctx.getOrganism()->GetID();
strstrm << "cp tmp.xmi " << neverclaimFile << "." << m_world->GetStats().GetUpdate() << "." << ctx.getOrganism()->GetID();
strstrm << ".xml";
if(system(strstrm.str().c_str())!=0) return 0.0;
@@ -3275,20 +3278,6 @@
double bonus = 0.0;
int mt, nt;
-
-/* if ((organism->getUMLModel()->getBonusInfo("spinw1") == 0) &&
- (organism->getUMLModel()->getBonusInfo("spinw2") == 0)) {
- return bonus;
- }
- if ((organism->getUMLModel()->getBonusInfo("scenario5") != 9) ||
- (organism->getUMLModel()->getBonusInfo("scenario6") != 4)) {
- return bonus;
- }*/
-/* if (organism->getUMLModel()->getBonusInfo("hydra") == 0){
- return bonus;
- }*/
-
-
// Ok. Subtract the number of edges from the maximum number of edges seen so far.
mt = mod->getMaxTrans();
nt = mod->numTrans();
@@ -3298,9 +3287,6 @@
bonus /= mt;
}
- // cap the amount of bonus.
- //if (bonus > 5) bonus = 5;
-
return bonus;
}
@@ -3346,4 +3332,46 @@
}
+double cTaskLib::Task_ViolateN1(cTaskContext& ctx) const {
+
+ std::ostringstream strstrm;
+ cOrganism* organism = ctx.getOrganism();
+ double bonus = 0;
+ if (organism->getParentXMI() == organism->getUMLModel()->getXMI()) {
+
+ bonus = organism->getParentBonus("not-n1");
+ } else {
+ if ((SpinCoprocess(ctx, "N1")) == 0) {
+ bonus = 1;
+ }
+ }
+
+ organism->getUMLModel()->setBonusInfo("not-n1", bonus);
+
+ if (bonus) {
+
+ strstrm << "cp tmp.xmi " << "violate-n1" << "." << m_world->GetStats().GetUpdate() << "." << ctx.getOrganism()->GetID();
+ strstrm << ".xml";
+ if(system(strstrm.str().c_str())!=0) return 0.0;
+ }
+
+ return bonus;
+}
+
+
+double cTaskLib::Task_ViolateN2(cTaskContext& ctx) const {
+
+ std::ostringstream strstrm;
+
+ double bonus = !(SpinCoprocess(ctx, "N2"));
+
+ if (bonus) {
+ strstrm << "cp tmp.xmi " << "violate-n2" << "." << m_world->GetStats().GetUpdate() << "." << ctx.getOrganism()->GetID();
+ strstrm << ".xml";
+ if(system(strstrm.str().c_str())!=0) return 0.0;
+ }
+
+ return bonus;
+}
+
Modified: branches/uml/source/main/cTaskLib.h
===================================================================
--- branches/uml/source/main/cTaskLib.h 2007-09-17 18:45:15 UTC (rev 2096)
+++ branches/uml/source/main/cTaskLib.h 2007-09-18 18:59:15 UTC (rev 2097)
@@ -302,6 +302,8 @@
// double Task_MultTrans(cTaskContext& ctx) const;
double Task_Nondeterminism(cTaskContext& ctx) const;
double Task_ExportXMI(cTaskContext& ctx) const;
+ double Task_ViolateN1(cTaskContext& ctx) const;
+ double Task_ViolateN2(cTaskContext& ctx) const;
};
Modified: branches/uml/source/main/cUMLStateDiagram.cc
===================================================================
--- branches/uml/source/main/cUMLStateDiagram.cc 2007-09-17 18:45:15 UTC (rev 2096)
+++ branches/uml/source/main/cUMLStateDiagram.cc 2007-09-18 18:59:15 UTC (rev 2097)
@@ -491,7 +491,7 @@
}
// int id_num = num_edges(sd0);
- std::cout << "Adding an edge with id " << edge_id_count << std::endl;
+// std::cout << "Adding an edge with id " << edge_id_count << std::endl;
// Create the transition properties
transition_properties tp = transition_properties(trigger_index, guard_index, action_index, edge_id_count);
@@ -515,7 +515,7 @@
// true; otherwise, return false.
bool cUMLStateDiagram::removeTransition(int x) {
- std::cout << "attempting to remove transition " << x << std::endl;
+// std::cout << "attempting to remove transition " << x << std::endl;
bool val = false;
boost::graph_traits<state_diagram>::edge_descriptor ed;
@@ -528,13 +528,13 @@
edge_start != edge_end; ++edge_start) {
ed = *edge_start;
- std::cout << "trans id is " << (sd0[ed]._eid) << std::endl;
+// std::cout << "trans id is " << (sd0[ed]._eid) << std::endl;
if (x == (sd0[ed]._eid)) {
remove_edge(ed, sd0);
val = true;
- std::cout << "removed " << x << std::endl;
+// std::cout << "removed " << x << std::endl;
break;
}
More information about the Avida-cvs
mailing list