[Rsiena-commits] r21 - pkg/RSiena/src/model/variables
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Nov 8 18:07:37 CET 2009
Author: ripleyrm
Date: 2009-11-08 18:07:35 +0100 (Sun, 08 Nov 2009)
New Revision: 21
Modified:
pkg/RSiena/src/model/variables/BehaviorVariable.cpp
pkg/RSiena/src/model/variables/BehaviorVariable.h
Log:
Bug fix to behavior variable scores
Modified: pkg/RSiena/src/model/variables/BehaviorVariable.cpp
===================================================================
--- pkg/RSiena/src/model/variables/BehaviorVariable.cpp 2009-11-05 22:48:19 UTC (rev 20)
+++ pkg/RSiena/src/model/variables/BehaviorVariable.cpp 2009-11-08 17:07:35 UTC (rev 21)
@@ -280,6 +280,8 @@
// change, respectivelly
double probabilities[3];
+ bool upPossible = true;
+ bool downPossible = true;
// Calculate the probability for downward change
@@ -293,6 +295,7 @@
else
{
probabilities[0] = 0;
+ downPossible = false;
}
// No change means zero contribution, but exp(0) = 1
@@ -309,6 +312,7 @@
else
{
probabilities[2] = 0;
+ upPossible = false;
}
if (this->pSimulation()->pModel()->needScores())
@@ -330,7 +334,7 @@
if (this->pSimulation()->pModel()->needScores())
{
- this->accumulateScores(difference + 1);
+ this->accumulateScores(difference + 1, upPossible, downPossible);
}
// Make the change
@@ -410,7 +414,8 @@
* Updates the scores for evaluation and endowment function effects according
* to the current step in the simulation.
*/
-void BehaviorVariable::accumulateScores(int difference) const
+void BehaviorVariable::accumulateScores(int difference,
+ bool upPossible, bool downPossible) const
{
for (unsigned i = 0;
i < this->pEvaluationFunction()->rEffects().size();
@@ -423,13 +428,20 @@
Effect * pEffect = this->pEvaluationFunction()->rEffects()[i];
double score = this->levaluationEffectContribution[difference][i];
- for (int j = 0; j < 3; j+=2)
+ if (upPossible)
{
score -=
- this->levaluationEffectContribution[j][i] *
- this->lprobabilities[j];
+ this->levaluationEffectContribution[2][i] *
+ this->lprobabilities[2];
}
+ if (downPossible)
+ {
+ score -=
+ this->levaluationEffectContribution[0][i] *
+ this->lprobabilities[0];
+ }
+
this->pSimulation()->score(pEffect->pEffectInfo(),
this->pSimulation()->score(pEffect->pEffectInfo()) + score);
}
@@ -449,11 +461,11 @@
Effect * pEffect = this->pEndowmentFunction()->rEffects()[i];
double score = this->lendowmentEffectContribution[difference][i];
- for (int j = 0; j < 2; j+=2)
+ if (downPossible)
{
score -=
- this->lendowmentEffectContribution[j][i] *
- this->lprobabilities[j];
+ this->lendowmentEffectContribution[0][i] *
+ this->lprobabilities[0];
}
Modified: pkg/RSiena/src/model/variables/BehaviorVariable.h
===================================================================
--- pkg/RSiena/src/model/variables/BehaviorVariable.h 2009-11-05 22:48:19 UTC (rev 20)
+++ pkg/RSiena/src/model/variables/BehaviorVariable.h 2009-11-08 17:07:35 UTC (rev 21)
@@ -63,7 +63,8 @@
int difference) const;
double totalEndowmentContribution(int actor,
int difference) const;
- void accumulateScores(int difference) const;
+ void accumulateScores(int difference, bool UpPossible,
+ bool downPossible) const;
// The observed data for this behavioral variable
BehaviorLongitudinalData * lpData;
More information about the Rsiena-commits
mailing list