[Rsiena-commits] r292 - in pkg/RSienaTest: . src/model/variables src/sim

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun May 22 20:06:40 CEST 2016


Author: fschoenen
Date: 2016-05-22 20:06:40 +0200 (Sun, 22 May 2016)
New Revision: 292

Modified:
   pkg/RSienaTest/ChangeLog
   pkg/RSienaTest/DESCRIPTION
   pkg/RSienaTest/src/model/variables/NetworkVariable.cpp
   pkg/RSienaTest/src/sim/StatisticsSimulation.cpp
Log:
fixed permission filter for 2-mode networks


Modified: pkg/RSienaTest/ChangeLog
===================================================================
--- pkg/RSienaTest/ChangeLog	2016-02-03 19:08:24 UTC (rev 291)
+++ pkg/RSienaTest/ChangeLog	2016-05-22 18:06:40 UTC (rev 292)
@@ -1,3 +1,7 @@
+2016-02-03 R-Forge Revision 292
+Changes in RSienaTest:
+   * Fixed permission filter for 2-mode networks.
+
 2016-02-03 R-Forge Revision 291
 Changes in RSienaTest:
    * Fixed include order.

Modified: pkg/RSienaTest/DESCRIPTION
===================================================================
--- pkg/RSienaTest/DESCRIPTION	2016-02-03 19:08:24 UTC (rev 291)
+++ pkg/RSienaTest/DESCRIPTION	2016-05-22 18:06:40 UTC (rev 292)
@@ -1,8 +1,8 @@
 Package: RSienaTest
 Type: Package
 Title: Siena - Simulation Investigation for Empirical Network Analysis
-Version: 1.1-291
-Date: 2016-02-03
+Version: 1.1-292
+Date: 2016-05-22
 Author: Ruth Ripley, Krists Boitmanis, Tom A.B. Snijders, Felix Schoenenberger
 Depends: R (>= 2.15.0), utils
 Imports: Matrix, tcltk, lattice, parallel, MASS, RUnit

Modified: pkg/RSienaTest/src/model/variables/NetworkVariable.cpp
===================================================================
--- pkg/RSienaTest/src/model/variables/NetworkVariable.cpp	2016-02-03 19:08:24 UTC (rev 291)
+++ pkg/RSienaTest/src/model/variables/NetworkVariable.cpp	2016-05-22 18:06:40 UTC (rev 292)
@@ -82,9 +82,9 @@
 	else
 	{
 		this->lpNetwork = new Network(this->n(), this->m());
-		numberOfAlters = this->m() + 1; 
-						// then numberOfAlters really is a misnomer
-		this->lpermitted = new bool[this->m()+1];
+		numberOfAlters = this->m() + 1;
+		// then numberOfAlters really is a misnomer
+		this->lpermitted = new bool[numberOfAlters];
 		this->levaluationEffectContribution = new double * [numberOfAlters];
 		this->lendowmentEffectContribution = new double * [numberOfAlters];
 		this->lcreationEffectContribution = new double * [numberOfAlters];
@@ -722,27 +722,27 @@
  */
 void NetworkVariable::calculatePermissibleChanges()
 {
-	NetworkLongitudinalData * pData =
-		(NetworkLongitudinalData *) this->pData();
+	NetworkLongitudinalData *pData = (NetworkLongitudinalData*) this->pData();
 
-	// Test each alter if a tie flip to that alter is permitted according
-	// to upOnly/downOnly flags and the max degree.
 	int m = this->m();
-
-	for (int i = 0; i < m; ++i) {
+	for (int i = 0; i < m; ++i)
+	{
 		this->lpermitted[i] = false;
 	}
 
 	Setting* curSetting = 0;
 	ITieIterator* iter = 0;
-	if (this->stepType() != -1) {
+	if (this->stepType() != -1)
+	{
 		curSetting = lsettings[stepType()];
 		iter = curSetting->getSteps();
 		m = curSetting->getSize();
 	}
-// Rprintf("MaxDegree %d \n", pData->maxDegree());
 
-	for (int ii = 0; ii < m; ii++) {
+  // Test each alter if a tie flip to that alter is permitted according to
+  // upOnly/downOnly flags and the max degree.
+	for (int ii = 0; ii < m; ii++)
+	{
 		int i = ii;
 		if (this->stepType() > -1) {
 			if (!iter->valid()) {
@@ -770,11 +770,8 @@
 	if (iter != 0) {
 		delete iter;
 	}
-	// ensure that no change is a permitted change
-	lpermitted[lego] = true;
 
 	// Prohibit the change of structural ties
-
 	for (IncidentTieIterator iter =
 			 pData->pStructuralTieNetwork(this->period())->outTies(this->lego);
 			iter.valid(); iter.next()) {
@@ -782,7 +779,6 @@
 	}
 
 	// Run the filters that may forbid some more changes
-
 	for (unsigned i = 0; i < this->lpermittedChangeFilters.size(); i++)
 	{
 		PermittedChangeFilter * pFilter = this->lpermittedChangeFilters[i];
@@ -790,21 +786,17 @@
 		pFilter->filterPermittedChanges(this->lego, this->lpermitted);
 		//Rprintf(" filtered %d %d\n ", i, this->lpermitted[10]);
 	}
-//	if (this->id() > 0)
-//	for (int i = 0; i < m; i++)
-//	 {
-//		 	 Rprintf("permitted %d %d %d\n", i, this->lpermitted[i], m);
-//	 }
 
-if (!this->oneModeNetwork())
-{
-			// It is okay to not make any change at all
-			this->lpermitted[m] = true;
+	// ensure that no change is a permitted change
+	if (this->oneModeNetwork())
+	{
+		this->lpermitted[lego] = true;
+	} else {
+		this->lpermitted[m] = true;
+	}
 }
 
-}
 
-
 /**
  * For each alter, this method calculates the contribution of each evaluation,
  * endowment, and tie creation effect if a tie from the ego to this alter was
@@ -819,12 +811,9 @@
 	int evaluationEffectCount = this->pEvaluationFunction()->rEffects().size();
 	int endowmentEffectCount = this->pEndowmentFunction()->rEffects().size();
 	int creationEffectCount = this->pCreationFunction()->rEffects().size();
-	const vector<Effect *> & rEvaluationEffects =
-		this->pEvaluationFunction()->rEffects();
-	const vector<Effect *> & rEndowmentEffects =
-		this->pEndowmentFunction()->rEffects();
-	const vector<Effect *> & rCreationEffects =
-		this->pCreationFunction()->rEffects();
+	const vector<Effect*> &rEvaluationEffects = this->pEvaluationFunction()->rEffects();
+	const vector<Effect*> &rEndowmentEffects = this->pEndowmentFunction()->rEffects();
+	const vector<Effect*> &rCreationEffects = this->pCreationFunction()->rEffects();
 	bool twoModeNetwork = !this->oneModeNetwork();
 	NetworkLongitudinalData * pData = (NetworkLongitudinalData *) this->pData();
 
@@ -832,7 +821,8 @@
 	int alter = 0;
 	Setting* curSetting = 0;
 	ITieIterator* permIter = 0;
-	if (this->stepType() != -1) {
+	if (this->stepType() != -1)
+	{
 		curSetting = lsettings[stepType()];
 		permIter = curSetting->getPermittedSteps();
 		m = curSetting->getPermittedSize();
@@ -1457,10 +1447,10 @@
 				if (permIter)
 				{
 					if (!permIter->valid())
-				{
+					{
 						LOGS(logger::Priority::ERROR)<< "iterator not valid\n";
 						throw "not valid";
-				}
+					}
 					j = permIter->actor();
 					permIter->next();
 				}
@@ -1496,15 +1486,15 @@
 				if (permIter)
 				{
 					if (!permIter->valid())
-				{
+					{
 						LOGS(logger::Priority::ERROR)<< "iterator not valid";
 						throw "not valid";
-				}
+					}
 					j = permIter->actor();
 					permIter->next();
 				}
 				if (!this->lpNetworkCache->outTieExists(j) &&
-					this->lpermitted[j])
+						this->lpermitted[j])
 				{
 					score -=
 						this->lcreationEffectContribution[j][i] *

Modified: pkg/RSienaTest/src/sim/StatisticsSimulation.cpp
===================================================================
--- pkg/RSienaTest/src/sim/StatisticsSimulation.cpp	2016-02-03 19:08:24 UTC (rev 291)
+++ pkg/RSienaTest/src/sim/StatisticsSimulation.cpp	2016-05-22 18:06:40 UTC (rev 292)
@@ -181,12 +181,12 @@
  */
 void StatisticsSimulation::simulatePeriods(bool withSeeds) {
 	GetRNGstate();
-#pragma omp parallel num_threads(lNThreads)
+	#pragma omp parallel num_threads(lNThreads)
 	{
-#pragma omp for schedule(dynamic, 1)
+		#pragma omp for schedule(dynamic, 1)
 		for (unsigned int thread = 0; thread < lNThreads; ++thread) {
 			// Run epoch simulation for each period
-			LOGS(Priority::DEBUG)<<"simulate with theta: "<<rParameters().transpose();
+			LOGS(Priority::DEBUG) << "simulate with theta: " << rParameters().transpose();
 			for (int m = 0; m < lpData->observationCount() - 1; ++m) {
 				if (withSeeds) {
 					setSeed(lSeeds[m]);



More information about the Rsiena-commits mailing list