Debian Codegraph @

src/dr/inference/markovjumps/StateChange.java

raw symbols SCIP
1 /*
2 * StateChange.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.markovjumps;
27
28 /**
29 * A class to represent a state-change in a continuous-time Markov chain.
30 * This class is equivalent to ColourChange in terms of parameters, but labels events
31 * more generically as either forward or backwards (instead of just backwards) in time.
32 * <p/>
33 * TODO Remove dr.evolution.tree.ColourChange (wrong package)
34 *
35 * @author Alexei Drummond
36 * @author Marc A. Suchard
37 * <p/>
38 * This work is supported by NSF grant 0856099
39 */
40
41 public class StateChange {
42
43 // time of the change in colour
44 private double time;
45
46 // the state associated with this time
47 private int state;
48
49 private int previousState;
50
51 public StateChange(StateChange change) {
52 this(change.time, change.state);
53 }
54
55 public StateChange(double time, int state, int previousState) {
56 this.time = time;
57 this.state = state;
58 this.previousState = previousState;
59 }
60
61 public StateChange(double time, int state) {
62 this.time = time;
63 this.state = state;
64 this.previousState = -1;
65 }
66
67 public StateChange clone() {
68 return new StateChange(time, state, previousState);
69 }
70
71 /**
72 * @return the time of this change in colour
73 */
74 public final double getTime() {
75 return time;
76 }
77
78 /**
79 * @return the state associated with the time
80 */
81 public final int getState() {
82 return state;
83 }
84
85 public final int getPreviousState() {
86 return previousState;
87 }
88
89 public final void setPreviousState(int state) {
90 this.previousState = state;
91 }
92
93 /**
94 * @param state sets the state of this event
95 */
96 public final void setState(int state) {
97 this.state = state;
98 }
99
100 public final void setTime(double time) {
101 this.time = time;
102 }
103
104 public String toString() {
105 StringBuilder sb = new StringBuilder();
106 sb.append("{").append(getTime()).append(",").append(getState()).append("}");
107 return sb.toString();
108 }
109 }