Skip to content

Commit

Permalink
Use sigmoid for inverse calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
koalo committed Oct 9, 2018
1 parent 8c15f4b commit 574cbfe
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/csma_model/Calculation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ PetscErrorCode CalculatePathReliability(DM& circuitdm, DMNetworkComponentGeneric
PetscFunctionReturn(0);
}

PetscScalar sigInv(PetscScalar y) {
return log(y/(1-y));
}

#undef __FUNCT__
#define __FUNCT__ "FormFunction"
PetscErrorCode FormFunction(SNES snes,Vec X, Vec F,void *appctx)
Expand Down Expand Up @@ -583,15 +587,7 @@ PetscErrorCode FormFunction(SNES snes,Vec X, Vec F,void *appctx)

ierr = DMNetworkGetVariableOffset(circuitdm,vEnd,&offset);CHKERRQ(ierr);

// in order to avoid zero pivot
if(R >= 0.9999) {
R += xarr[offset];
}
else {
R += 0.00001*xarr[offset];
}

farr[offset] = R-user->inverse;
farr[offset] = sigInv(R)-sigInv(user->inverse);
}

ierr = VecRestoreArrayRead(localX,&xarr);CHKERRQ(ierr);
Expand Down

0 comments on commit 574cbfe

Please sign in to comment.