View Javadoc

1   /*
2    * Copyright 2013 University of Glasgow.
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 broadwick.montecarlo;
17  
18  import broadwick.utils.CloneUtils;
19  import java.io.Serializable;
20  import lombok.Getter;
21  import lombok.Setter;
22  
23  /**
24   * A simple model class thats runs a model and creates named quantities, i.e. a map containing the vlaues and their
25   * names.
26   */
27  public abstract class MonteCarloScenario implements Serializable {
28  
29      /**
30       * Compute the value of the Monte Carlo model/simulation at the given set of coordinates.
31       * @param seed a seed for the random number generator in the scenario. Scenarios are created so quickly, relying on
32       * the clock as a seed may lead to a lot of generator with the same sequence.
33       * @return a Monte Carlo Results object.
34       */
35      public abstract MonteCarloResults run(final int seed);
36      
37      
38      /**
39       * Create a copy of the MonteCarloScenario object. This is used by the MonteCarlo producer object to create a 
40       * copy of each scenario object, allowing for each scenario to control which attributes are deep or shallow copied.
41       * @return a (deep) copy of the MonteCarloScenario object.
42       */
43      public MonteCarloScenario copyOf() {
44          return (MonteCarloScenario) CloneUtils.deepClone(this);
45      }
46      
47      @Getter
48      @Setter
49      MonteCarloStep step;
50  }