summaryrefslogtreecommitdiff
path: root/java/src/org/singinst/uf/model/MooresLawNodeMetadataContentsFactory.java
blob: 98224bc7b22d8e8ca7adb1a944e018fc2c012003 (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
package org.singinst.uf.model;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.singinst.uf.presenter.HtmlUtil;
import org.singinst.uf.presenter.ScalarValuePointList;
import org.singinst.uf.presenter.LineBounds;

class MooresLawNodeMetadataContentsFactory {
	private final List<MooreAsymptote> asymptotes = new ArrayList<MooreAsymptote>();
	private final List<ScalarSchema> scalarSchemata = new ArrayList<ScalarSchema>();
	private final List<ScalarValueHolder> scalarValueHolders = new ArrayList<ScalarValueHolder>();
	private final ScalarRelation relation;
	
	public MooresLawNodeMetadataContentsFactory(Node node) {
		LineBounds yearDomain = new LineBounds(1950, 2070);
		Axis year = new Axis(yearDomain);
		Axis flopsPerDollar = new Axis(new LineBounds(-4, 18, true));

		int asymptoteLowerBound = 8;
		for (NotablePercentile percentile : NotablePercentile.values()) {
			LineBounds asymptoteRange = new LineBounds(asymptoteLowerBound, 18);
			MooreAsymptote asymptote = new MooreAsymptote(node, yearDomain, asymptoteRange, percentile);
			asymptotes.add(asymptote);
			scalarSchemata.add(asymptote.getScalar());
			scalarValueHolders.add(asymptote.getConjecture());
			asymptoteLowerBound += 2;
		}
		new MooreConstraint(getScalars()).constrain();
		
		relation = new ScalarRelation(year, flopsPerDollar, MooresLawData.getInstance().points) {

			public List<? extends ConclusionReportGenerator> getConclusionGenerators() {
				return Collections.singletonList(new ConclusionReportGenerator() {

					public String getText(ScalarValueHolder scalarValueHolder, double value) {
						return "The limiting value of log(FLOPS/dollar) has a 90% chance of being between " +
						HtmlUtil.green(getScalars().get(0).getScalarValueHolder().getValue()) + 
						" and " + HtmlUtil.red(getScalars().get(2).getScalarValueHolder().getValue());
					}

				});
			}

			public List<ScalarValueHolder> getScalarValues() {
				return scalarValueHolders;
			}

			@Override
			public List<ScalarValuePointList> getPointLists() {
				List<ScalarValuePointList> retVal = new ArrayList<ScalarValuePointList>();
				for (MooreAsymptote asymptote : asymptotes) {
					retVal.addAll(asymptote.getPointLists());
				}
				return retVal;
			}			
		};

	}
	public ScalarRelation getRelation() {
		return relation;
	}
	public List<ScalarSchema> getScalars() {
		return scalarSchemata;
	}
}