summaryrefslogtreecommitdiff
path: root/java/src/org/singinst/uf/model/AiRelation.java
blob: 7be8b43a23eb8ca8940e033ef3f784bbb12a5cbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package org.singinst.uf.model;

import java.awt.Color;

import org.singinst.uf.math.MathUtil;



public class AiRelation extends YearwiseCalculationRelation {

	public boolean displayHtml;
	
	public AiRelation(Node node) {
		super(node);
//		this.displayHtml = displayHtml;
	}

	@Override
	protected Calculation getCalculation(double year) {
		return new MultiplicationCalculation("Probability of either sort of AI by year " + (int) year, 
				probabilityAiIfAiIsPossible(year),
				probabilityAiIsPossible());

	}

	private Calculation probabilityAiIfAiIsPossible(final double year) {
		return new Calculation("Probability of AI (if AI is possible) by year " + (int) year) {

			@Override
			protected double rawEvaluate(StringBuilder htmlConsole) {
				return MathUtil.expc(
					  MathUtil.clog(
							ScalarValueHolder.findById(NodeIDString.C1_5, ScalarSubIDString.yearProbabilityID(year)).evaluate(new StringBuilder())
						  / probabilityAiIsPossible().evaluate()
					  )
					+ MathUtil.clog(getNonNeuromorphicAiCalculationForYear(year).evaluate())
				);
			}
			
			@Override
			public Color getColor() {
				return Color.BLUE;
			}
		};
/*				ScalarValueHolder.get(NodeIDString.C1_5, yearScalarName(year)),
				getNonNeuromorphicAiCalculationForYear(year)) {
			@Override
			protected double rawEvaluate(StringBuilder htmlConsole) {
				double probabilityOfNot = 1;
				for (Evaluable calculation : getCalculations()) {
					probabilityOfNot *= (1 - calculation.evaluate(htmlConsole));
				}
				htmlConsole.append(getDescription());
				return 1 - probabilityOfNot;
			}
		};*/
	}
	private Calculation getNonNeuromorphicAiCalculationForYear(final double year) {
		return new Calculation("Probability that non-neuromorphic AI will be created by year " + year, false) {

			@Override
			protected double rawEvaluate(StringBuilder htmlConsole) {
				double mean = ScalarValueHolder.findById(NodeIDString.Q1_6, ScalarSubIDString.MEAN).getValue();
				double stdDev = ScalarValueHolder.findById(NodeIDString.Q1_6, ScalarSubIDString.STD_DEV).getValue();
				return MathUtil.cumulativeNormalDistribution(mean, stdDev, Math.log10(year - ModelUtil.ANCHOR_FAR_YEAR));
			}
		};
	}
}