EMlab-generation Documentation  1.0
Documentation of the EMLab-Generation model.
StepTrend.java
1 /*******************************************************************************
2  * Copyright 2012 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 package emlab.gen.trend;
17 
18 import org.springframework.data.neo4j.annotation.NodeEntity;
19 
20 import agentspring.simulation.SimulationParameter;
21 import agentspring.trend.Trend;
22 
23 @NodeEntity
24 public class StepTrend extends TimeSeriesImpl implements Trend {
25 
26  @SimulationParameter(label = "Time steps per step", from = 0, to = 50)
27  private double duration;
28 
29  @SimulationParameter(label = "Increment per step")
30  private double increment;
31 
32  private double minValue;
33 
34  @SimulationParameter(label = "Start value", from = 200e6, to =300e6)
35  private double start;
36 
37  public double getDuration() {
38  return duration;
39  }
40 
41  public double getMinValue() {
42  return minValue;
43  }
44 
45  public void setMinValue(double minValue) {
46  this.minValue = minValue;
47  }
48 
49  public void setDuration(double duration) {
50  this.duration = duration;
51  }
52 
53  public double getIncrement() {
54  return increment;
55  }
56 
57  public void setIncrement(double increment) {
58  this.increment = increment;
59  }
60 
61  @Override
62  public double getValue(long time) {
63  return Math.max(minValue, getStart() + Math.floor(time / duration) * increment);
64  }
65 
66  public double getStart() {
67  return start;
68  }
69 
70  public void setStart(double start) {
71  this.start = start;
72  }
73 
74 }