Debian Codegraph @

src/dr/inference/trace/ArrayTraceList.java

raw symbols SCIP
1 /*
2 * ArrayTraceList.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.inference.trace;
27
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31
32 /**
33 * @author Alexei Drummond
34 */
35 public class ArrayTraceList extends AbstractTraceList {
36
37 String name;
38 Map<String, Integer> traceIndex = new HashMap<String, Integer>();
39 long burnin = 0;
40 List<Trace> traces;
41 long stepSize;
42
43 public ArrayTraceList(String name, List<Trace> traces, int burnin) {
44 this.name = name;
45 this.traces = traces;
46 this.burnin = burnin;
47
48 for (int i = 0; i < traces.size(); i++) {
49 traceIndex.put(traces.get(i).getName(), i);
50 }
51
52 Trace stateTrace = traces.get(0);
53 this.stepSize = (int) Math.round((Double) stateTrace.getValue(1) - (Double) stateTrace.getValue(0));
54 }
55
56 public String getName() {
57 return name;
58 }
59
60 public String getFullName() {
61 return name;
62 }
63
64 public int getTraceCount() {
65 return traces.size();
66 }
67
68 public int getTraceIndex(String name) {
69 Integer index = traceIndex.get(name);
70 if (index == null) return -1;
71 return index;
72 }
73
74 public String getTraceName(int index) {
75 return traces.get(index).getName();
76 }
77
78 /**
79 * @return the burn-in for this trace list (the number of sampled states to discard)
80 */
81 public long getBurnIn() {
82 return burnin;
83 }
84
85 /**
86 * @return the number of states in the traces (after burnin removed)
87 */
88 public int getStateCount() {
89 return traces.get(0).getValueCount();
90 }
91
92 /**
93 * @return the number of states in the burnin
94 */
95 public int getBurninStateCount() {
96 return (int) (getBurnIn() / (long) stepSize);
97 }
98
99 public long getStepSize() {
100 return stepSize;
101 }
102
103 public long getMaxState() {
104 return getStateCount() * getStepSize();
105 }
106
107 public boolean isIncomplete() {
108 return false;
109 }
110
111 public List<Double> getValues(int index, int fromIndex, int toIndex) {
112 throw new UnsupportedOperationException("not available");
113 }
114
115 public List<Double> getValues(int index) {
116 throw new UnsupportedOperationException("not available");
117 }
118
119 public List<Double> getBurninValues(int index) {
120 throw new UnsupportedOperationException("not available");
121 }
122
123 public Trace getTrace(int index) {
124 return traces.get(index);
125 }
126 }