[Avida-SVN] r1833 - in branches/energy_dev/source: cpu main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Fri Jul 20 13:27:02 PDT 2007
Author: beckma24
Date: 2007-07-20 16:27:02 -0400 (Fri, 20 Jul 2007)
New Revision: 1833
Modified:
branches/energy_dev/source/cpu/cHardwareExperimental.cc
branches/energy_dev/source/cpu/cHardwareExperimental.h
branches/energy_dev/source/cpu/cHardwareGX.cc
branches/energy_dev/source/cpu/cHardwareGX.h
branches/energy_dev/source/cpu/cHardwareSMT.cc
branches/energy_dev/source/cpu/cHardwareSMT.h
branches/energy_dev/source/cpu/cHardwareTransSMT.cc
branches/energy_dev/source/cpu/cHardwareTransSMT.h
branches/energy_dev/source/main/cAvidaConfig.h
branches/energy_dev/source/main/cBirthChamber.cc
branches/energy_dev/source/main/cPhenotype.cc
branches/energy_dev/source/main/cResourceCount.cc
Log:
Fixed energy bug: on birth energy bouns was not added to energy total, just merit. Removed redundent code
Modified: branches/energy_dev/source/cpu/cHardwareExperimental.cc
===================================================================
--- branches/energy_dev/source/cpu/cHardwareExperimental.cc 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/cpu/cHardwareExperimental.cc 2007-07-20 20:27:02 UTC (rev 1833)
@@ -316,35 +316,6 @@
CheckImplicitRepro(ctx);
}
-
-// This method will test to see if all costs have been paid associated
-// with executing an instruction and only return true when that instruction
-// should proceed.
-/*bool cHardwareExperimental::SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst)
-{
-#if INSTRUCTION_COSTS
- assert(cur_inst.GetOp() < inst_cost.GetSize());
-
- // If first time cost hasn't been paid off...
- if (m_has_ft_costs && inst_ft_cost[cur_inst.GetOp()] > 0) {
- inst_ft_cost[cur_inst.GetOp()]--; // dec cost
- return false;
- }
-
- // Next, look at the per use cost
- if (m_has_costs && m_inst_set->GetCost(cur_inst) > 0) {
- if (inst_cost[cur_inst.GetOp()] > 1) { // if isn't paid off (>1)
- inst_cost[cur_inst.GetOp()]--; // dec cost
- return false;
- } else { // else, reset cost array
- inst_cost[cur_inst.GetOp()] = m_inst_set->GetCost(cur_inst);
- }
- }
-
-#endif
- return true;
-}*/
-
// This method will handle the actuall execution of an instruction
// within single process, once that function has been finalized.
bool cHardwareExperimental::SingleProcess_ExecuteInst(cAvidaContext& ctx, const cInstruction& cur_inst)
Modified: branches/energy_dev/source/cpu/cHardwareExperimental.h
===================================================================
--- branches/energy_dev/source/cpu/cHardwareExperimental.h 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/cpu/cHardwareExperimental.h 2007-07-20 20:27:02 UTC (rev 1833)
@@ -136,16 +136,6 @@
bool m_advance_ip; // Should the IP advance after this instruction?
bool m_executedmatchstrings; // Have we already executed the match strings instruction?
- // Instruction costs...
-/*#if INSTRUCTION_COSTS
- tArray<int> inst_cost;
- tArray<int> inst_ft_cost;
- bool m_has_costs;
- bool m_has_ft_costs;
-#endif
-
-
- bool SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst);*/
bool SingleProcess_ExecuteInst(cAvidaContext& ctx, const cInstruction& cur_inst);
// -------- Stack Manipulation... --------
Modified: branches/energy_dev/source/cpu/cHardwareGX.cc
===================================================================
--- branches/energy_dev/source/cpu/cHardwareGX.cc 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/cpu/cHardwareGX.cc 2007-07-20 20:27:02 UTC (rev 1833)
@@ -583,36 +583,6 @@
// organism->SetRunning(false);
//}
-
-// This method will test to see if all costs have been paid associated
-// with executing an instruction and only return true when that instruction
-// should proceed.
-/*bool cHardwareGX::SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst)
-{
-#if INSTRUCTION_COSTS
- assert(cur_inst.GetOp() < inst_cost.GetSize());
-
- // If first time cost hasn't been paid off...
- if ( inst_ft_cost[cur_inst.GetOp()] > 0 ) {
- inst_ft_cost[cur_inst.GetOp()]--; // dec cost
- return false;
- }
-
- // Next, look at the per use cost
- if ( m_inst_set->GetCost(cur_inst) > 0 ) {
- if ( inst_cost[cur_inst.GetOp()] > 1 ){ // if isn't paid off (>1)
- inst_cost[cur_inst.GetOp()]--; // dec cost
- return false;
- } else { // else, reset cost array
- inst_cost[cur_inst.GetOp()] = m_inst_set->GetCost(cur_inst);
- }
- }
-
-#endif
- return true;
-}*/
-
-
/*! This method executes one instruction for one programid. */
bool cHardwareGX::SingleProcess_ExecuteInst(cAvidaContext& ctx, const cInstruction& cur_inst)
{
Modified: branches/energy_dev/source/cpu/cHardwareGX.h
===================================================================
--- branches/energy_dev/source/cpu/cHardwareGX.h 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/cpu/cHardwareGX.h 2007-07-20 20:27:02 UTC (rev 1833)
@@ -259,14 +259,6 @@
bool m_reset_inputs; // Flag to make it easy for instructions to reset all inputs (force task modularity).
bool m_reset_heads; // Flas to make it easy for instructions to reset heads back (force task modularity).
- // Instruction costs...
-/*#if INSTRUCTION_COSTS
- tArray<int> inst_cost;
- tArray<int> inst_ft_cost;
-#endif
-
-
- bool SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst);*/
bool SingleProcess_ExecuteInst(cAvidaContext& ctx, const cInstruction& cur_inst);
// -------- Stack Manipulation... --------
Modified: branches/energy_dev/source/cpu/cHardwareSMT.cc
===================================================================
--- branches/energy_dev/source/cpu/cHardwareSMT.cc 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/cpu/cHardwareSMT.cc 2007-07-20 20:27:02 UTC (rev 1833)
@@ -266,39 +266,6 @@
CheckImplicitRepro(ctx);
}
-
-// This method will test to see if all costs have been paid associated
-// with executing an instruction and only return true when that instruction
-// should proceed.
-/*bool cHardwareSMT::SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst)
-{
-#if INSTRUCTION_COSTS
- assert(cur_inst.GetOp() < inst_cost.GetSize());
-
- // If first time cost hasn't been paid off...
- if (m_has_ft_costs && inst_ft_cost[cur_inst.GetOp()] > 0) {
- inst_ft_cost[cur_inst.GetOp()]--; // dec cost
- return false;
- }
-
- // Next, look at the per use cost
- if (m_has_costs && m_inst_set->GetCost(cur_inst) > 0) {
- if (inst_cost[cur_inst.GetOp()] > 1) { // if isn't paid off (>1)
- inst_cost[cur_inst.GetOp()]--; // dec cost
- return false;
- } else { // else, reset cost array
- inst_cost[cur_inst.GetOp()] = m_inst_set->GetCost(cur_inst);
- }
- }
-
- // Prob of exec
- if ( m_inst_set->GetProbFail(cur_inst) > 0.0 ){
- return !( ctx.GetRandom().P(m_inst_set->GetProbFail(cur_inst)) );
- }
-#endif
- return true;
-}*/
-
// This method will handle the actual execution of an instruction
// within single process, once that function has been finalized.
bool cHardwareSMT::SingleProcess_ExecuteInst(cAvidaContext& ctx, const cInstruction& cur_inst)
Modified: branches/energy_dev/source/cpu/cHardwareSMT.h
===================================================================
--- branches/energy_dev/source/cpu/cHardwareSMT.h 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/cpu/cHardwareSMT.h 2007-07-20 20:27:02 UTC (rev 1833)
@@ -124,15 +124,6 @@
int m_cur_thread;
int m_cur_child;
- // Instruction costs...
-/*#if INSTRUCTION_COSTS
- tArray<int> inst_cost;
- tArray<int> inst_ft_cost;
- bool m_has_costs;
- bool m_has_ft_costs;
-#endif
-
- bool SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst);*/
bool SingleProcess_ExecuteInst(cAvidaContext& ctx, const cInstruction& cur_inst);
Modified: branches/energy_dev/source/cpu/cHardwareTransSMT.cc
===================================================================
--- branches/energy_dev/source/cpu/cHardwareTransSMT.cc 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/cpu/cHardwareTransSMT.cc 2007-07-20 20:27:02 UTC (rev 1833)
@@ -263,39 +263,6 @@
CheckImplicitRepro(ctx);
}
-
-// This method will test to see if all costs have been paid associated
-// with executing an instruction and only return true when that instruction
-// should proceed.
-/*bool cHardwareTransSMT::SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst)
-{
-#if INSTRUCTION_COSTS
- assert(cur_inst.GetOp() < inst_cost.GetSize());
-
- // If first time cost hasn't been paid off...
- if (m_has_ft_costs && inst_ft_cost[cur_inst.GetOp()] > 0) {
- inst_ft_cost[cur_inst.GetOp()]--; // dec cost
- return false;
- }
-
- // Next, look at the per use cost
- if (m_has_costs && m_inst_set->GetCost(cur_inst) > 0) {
- if (inst_cost[cur_inst.GetOp()] > 1) { // if isn't paid off (>1)
- inst_cost[cur_inst.GetOp()]--; // dec cost
- return false;
- } else { // else, reset cost array
- inst_cost[cur_inst.GetOp()] = m_inst_set->GetCost(cur_inst);
- }
- }
-
- // Prob of exec
- if (m_inst_set->GetProbFail(cur_inst) > 0.0) {
- return !( ctx.GetRandom().P(m_inst_set->GetProbFail(cur_inst)) );
- }
-#endif
- return true;
-}*/
-
// This method will handle the actual execution of an instruction
// within single process, once that function has been finalized.
bool cHardwareTransSMT::SingleProcess_ExecuteInst(cAvidaContext& ctx, const cInstruction& cur_inst)
Modified: branches/energy_dev/source/cpu/cHardwareTransSMT.h
===================================================================
--- branches/energy_dev/source/cpu/cHardwareTransSMT.h 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/cpu/cHardwareTransSMT.h 2007-07-20 20:27:02 UTC (rev 1833)
@@ -123,15 +123,6 @@
int m_cur_thread;
int m_cur_child;
- // Instruction costs...
-/*#if INSTRUCTION_COSTS
- tArray<int> inst_cost;
- tArray<int> inst_ft_cost;
- bool m_has_costs;
- bool m_has_ft_costs;
-#endif
-
- bool SingleProcess_PayCosts(cAvidaContext& ctx, const cInstruction& cur_inst);*/
bool SingleProcess_ExecuteInst(cAvidaContext& ctx, const cInstruction& cur_inst);
Modified: branches/energy_dev/source/main/cAvidaConfig.h
===================================================================
--- branches/energy_dev/source/main/cAvidaConfig.h 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/main/cAvidaConfig.h 2007-07-20 20:27:02 UTC (rev 1833)
@@ -350,7 +350,7 @@
CONFIG_ADD_VAR(NUM_INST_EXC_BEFORE_0_ENERGY, int, 0, "Number of instructions executed before energy is exhausted.");
CONFIG_ADD_VAR(ENERGY_CAP, int, -1, "Maximum amount of energy that can be stored in an organism. -1 means the cap is set to Max Int"); // TODO - is this done?
CONFIG_ADD_VAR(APPLY_ENERGY_METHOD, int, 0, "When should rewarded energy be applied to current energy?\n0 = on divide\n1 = on completion of task\n2 = on sleep");
- CONFIG_ADD_VAR(ENERGY_VERBOSE, bool, 0, "Print energy and merit values. 0/1 (off/on)");
+// CONFIG_ADD_VAR(ENERGY_VERBOSE, bool, 0, "Print energy and merit values. 0/1 (off/on)");
CONFIG_ADD_VAR(LOG_SLEEP_TIMES, bool, 0, "Log sleep start and end times. 0/1 (off/on)\nWARNING: may use lots of memory.");
// CONFIG_ADD_VAR(FIX_METABOLIC_RATE, bool, 0, "When activated the metabolic rate of all orgiansims are equal. 0/1 (off/on)"); // TODO - check for correctness
Modified: branches/energy_dev/source/main/cBirthChamber.cc
===================================================================
--- branches/energy_dev/source/main/cBirthChamber.cc 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/main/cBirthChamber.cc 2007-07-20 20:27:02 UTC (rev 1833)
@@ -158,7 +158,6 @@
merit_array.Resize(1);
if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1) {
-// double energy_cap = (double) m_world->GetConfig().ENERGY_CAP.Get();
// calculate energy to be given to child
double child_energy = parent.GetPhenotype().ExtractParentEnergy();
Modified: branches/energy_dev/source/main/cPhenotype.cc
===================================================================
--- branches/energy_dev/source/main/cPhenotype.cc 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/main/cPhenotype.cc 2007-07-20 20:27:02 UTC (rev 1833)
@@ -1231,7 +1231,6 @@
double energy_given_at_birth = m_world->GetConfig().ENERGY_GIVEN_AT_BIRTH.Get();
double frac_parent_energy_given_at_birth = m_world->GetConfig().FRAC_PARENT_ENERGY_GIVEN_AT_BIRTH.Get();
double frac_energy_decay_at_birth = m_world->GetConfig().FRAC_ENERGY_DECAY_AT_BIRTH.Get();
- int inst_2_exc = m_world->GetConfig().NUM_INST_EXC_BEFORE_0_ENERGY.Get();
double energy_cap = (double) m_world->GetConfig().ENERGY_CAP.Get();
// apply energy if APPLY_ENERGY_METHOD is set to "on divide" (0)
@@ -1247,10 +1246,10 @@
double child_energy = min(GetStoredEnergy() * frac_parent_energy_given_at_birth + energy_given_at_birth, energy_cap);
// adjust energy in parent
- ReduceEnergy(child_energy - energy_given_at_birth);
+ ReduceEnergy(child_energy - 2*energy_given_at_birth); // 2*energy_given_at_birth: 1 in child_energy & 1 for parent
//TODO: add energy_given_at_birth to Stored_energy
- cMerit parentMerit = cMerit(min(cMerit::EnergyToMerit(GetStoredEnergy() + energy_given_at_birth, m_world), energy_cap));
+ cMerit parentMerit = cMerit(min(cMerit::EnergyToMerit(GetStoredEnergy(), m_world), energy_cap));
SetMerit(parentMerit);
/* if(m_world->GetConfig().ENERGY_VERBOSE.Get()) {
Modified: branches/energy_dev/source/main/cResourceCount.cc
===================================================================
--- branches/energy_dev/source/main/cResourceCount.cc 2007-07-20 19:21:39 UTC (rev 1832)
+++ branches/energy_dev/source/main/cResourceCount.cc 2007-07-20 20:27:02 UTC (rev 1833)
@@ -198,8 +198,12 @@
geo_name = "GRID";
} else if (in_geometry == nGeometry::TORUS) {
geo_name = "TORUS";
+ } else {
+ cerr << "[cResourceCount::Setup] Unknown resource geometry " << in_geometry << ". Exiting.";
+ exit(2);
}
+
/* If the verbose flag is set print out information about resources */
if (verbosity_level > VERBOSE_NORMAL) {
More information about the Avida-cvs
mailing list