Skip to content

Commit ac422d3

Browse files
Add files via upload
1 parent c889e62 commit ac422d3

14 files changed

+1274
-514
lines changed

src/main/scala/delSAT.scala

Lines changed: 242 additions & 120 deletions
Large diffs are not rendered by default.

src/main/scala/diff/DifferentialFunctionFactoryStasp.scala

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,50 +11,7 @@
1111

1212
package diff
1313

14-
import com.accelad.math.nilgiri.autodiff.{AbstractUnaryFunction, DifferentialFunction, DifferentialFunctionFactory, Variable}
14+
import com.accelad.math.nilgiri.autodiff.DifferentialFunctionFactory
1515
import com.accelad.math.nilgiri.{DoubleReal, DoubleRealFactory}
1616

17-
class DifferentialFunctionFactoryStasp extends DifferentialFunctionFactory[DoubleReal](DoubleRealFactory.instance()) {
18-
19-
class SCAbstractUnaryFunction(iX: DifferentialFunction[DoubleReal]) extends AbstractUnaryFunction[DoubleReal](iX: DifferentialFunction[DoubleReal]) {
20-
21-
override def getValue: DoubleReal = new DoubleReal(getReal) //rNFactory.phi(arg().getValue())
22-
23-
override def getReal: Double = {
24-
25-
assert(false, "differential function phi() should not be called from prasp2")
26-
27-
val uncertainAtomIndex = arg().getReal.toInt // must be toAbsEli positive Eli
28-
29-
-1d // dummy
30-
31-
}
32-
33-
@deprecated override def diff(i_v: Variable[DoubleReal]): DifferentialFunction[DoubleReal] = { // subject to removal in one of the next versions of DelSAT
34-
35-
//prt("Diff phi wrt " + i_v + "...")
36-
37-
if (i_v.getName.stripPrefix("anyPwPrForAtom_").toDouble == arg().getValue().getReal)
38-
39-
// We are returning the partial derivative d/dx, where x = i_v is toAbsEli variable with name "anyPwPrForAtom_"+uai, with uai being the index
40-
// of an uncertain atom ua. Since phi(uai) is defined as sum(probabilities of all pws where atom ua holds), the result is
41-
// either 1 (if this sum is differentiated against the probability variable of any possible world where atom ua holds) or 0 (otherwise).
42-
43-
one
44-
45-
else
46-
47-
zero
48-
49-
}
50-
51-
override def toString: String = "phi(" + arg.toString + ")"
52-
53-
override def getFormula(variables: java.util.List[Variable[DoubleReal]]): String = "phi(" + arg.getFormula(variables) + ")"
54-
55-
}
56-
57-
def phi(iX /*index of a measured atom (not an eli(!), since we don't have elis yet when this function is generated)*/ :
58-
DifferentialFunction[DoubleReal]) = new SCAbstractUnaryFunction(iX)
59-
60-
}
17+
class DifferentialFunctionFactoryStasp extends DifferentialFunctionFactory[DoubleReal](DoubleRealFactory.instance()) { }

src/main/scala/diff/UncertainAtomsSeprt.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
import com.accelad.math.nilgiri.DoubleReal;
1515
import com.accelad.math.nilgiri.autodiff.DifferentialFunction;
16+
import com.accelad.math.nilgiri.autodiff.Variable;
17+
import scala.Int;
1618

1719
import java.io.Serializable;
1820

@@ -21,23 +23,24 @@ public class UncertainAtomsSeprt implements Serializable { // for interoperabil
2123

2224
public String parameterAtomsSeq[];
2325

24-
public String measuredAtomsSeq[]; // within delSAT, the set of measured atoms is considered to be identical to the set ofparameter atoms
25-
// (whereas the called of delSAT might distinguish with them, e.g., for inductive logic programming / weight learning purposes)
26+
public String measuredAtomsSeq[];
2627

2728
public DifferentialFunction<DoubleReal> innerCostExpressionInstances[];
2829

29-
public String costFunAsPredicate; // null or an unary predicate with #c as argument
30+
public scala.collection.mutable.HashMap<Int, Variable<DoubleReal>> eliToVariableInCostFunctions;
31+
32+
//public String costFunAsPredicate; // null or an unary predicate with #c as argument
3033

3134
public UncertainAtomsSeprt(String parameterAtomsSeq[], String measuredAtomsSeq[], DifferentialFunction<DoubleReal> innerCostExpressionInstances[],
32-
String costFunAsPredicate) {
35+
scala.collection.mutable.HashMap<Int, Variable<DoubleReal>> eliToVariableInCostFunctions) {
3336

3437
this.parameterAtomsSeq = parameterAtomsSeq;
3538

3639
this.measuredAtomsSeq = measuredAtomsSeq;
3740

3841
this.innerCostExpressionInstances = innerCostExpressionInstances;
3942

40-
this.costFunAsPredicate = costFunAsPredicate;
43+
this.eliToVariableInCostFunctions = eliToVariableInCostFunctions;
4144

4245
}
4346

0 commit comments

Comments
 (0)