[2229] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using System;
|
---|
[2180] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Data.Linq;
|
---|
| 26 | using System.Data.Linq.Mapping;
|
---|
| 27 | using System.Text;
|
---|
| 28 |
|
---|
[2194] | 29 | namespace HeuristicLab.Modeling.Database.SQLServerCompact {
|
---|
[2180] | 30 | [Table(Name = "Model")]
|
---|
[2195] | 31 | public class Model : IModel {
|
---|
[2180] | 32 | public Model() {
|
---|
| 33 | targetVariable = default(EntityRef<Variable>);
|
---|
[2371] | 34 | algorithm = default(EntityRef<Algorithm>);
|
---|
[2180] | 35 | }
|
---|
| 36 |
|
---|
[2371] | 37 | public Model(Variable targetVariable, Algorithm algorithm, ModelType modelType)
|
---|
[2180] | 38 | : this() {
|
---|
[2203] | 39 | this.targetVariableId = targetVariable.Id;
|
---|
| 40 | this.algorithmId = algorithm.Id;
|
---|
[2371] | 41 | ModelType = modelType.ToString();
|
---|
[2180] | 42 | }
|
---|
| 43 |
|
---|
| 44 | private int id;
|
---|
| 45 | [Column(Storage = "id", IsPrimaryKey = true, IsDbGenerated = true)]
|
---|
| 46 | public int Id {
|
---|
| 47 | get { return this.id; }
|
---|
[2389] | 48 | set { this.id = value; }
|
---|
[2180] | 49 | }
|
---|
| 50 |
|
---|
| 51 | private int algorithmId;
|
---|
| 52 | [Column(Storage = "algorithmId", CanBeNull = false)]
|
---|
| 53 | public int AlgorithmId {
|
---|
| 54 | get { return this.algorithmId; }
|
---|
| 55 | private set {
|
---|
| 56 | if (algorithmId != value) {
|
---|
| 57 | if (algorithm.HasLoadedOrAssignedValue)
|
---|
| 58 | throw new ForeignKeyReferenceAlreadyHasValueException();
|
---|
| 59 | algorithmId = value;
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | private EntityRef<Algorithm> algorithm;
|
---|
| 65 | [Association(Storage = "algorithm", ThisKey = "AlgorithmId", OtherKey = "Id", IsForeignKey = true)]
|
---|
[2197] | 66 | public Algorithm Algorithm {
|
---|
[2180] | 67 | get { return this.algorithm.Entity; }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
[2197] | 70 | IAlgorithm IModel.Algorithm {
|
---|
| 71 | get { return this.Algorithm; }
|
---|
| 72 | }
|
---|
| 73 |
|
---|
[2180] | 74 | private int targetVariableId;
|
---|
| 75 | [Column(Storage = "targetVariableId", CanBeNull = false)]
|
---|
| 76 | public int TargetVariableId {
|
---|
| 77 | get { return this.targetVariableId; }
|
---|
| 78 | private set {
|
---|
| 79 | if (targetVariableId != value) {
|
---|
| 80 | if (targetVariable.HasLoadedOrAssignedValue)
|
---|
| 81 | throw new ForeignKeyReferenceAlreadyHasValueException();
|
---|
| 82 | targetVariableId = value;
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | private EntityRef<Variable> targetVariable;
|
---|
| 88 | [Association(Storage = "targetVariable", ThisKey = "TargetVariableId", OtherKey = "Id", IsForeignKey = true)]
|
---|
[2197] | 89 | public Variable TargetVariable {
|
---|
[2180] | 90 | get { return this.targetVariable.Entity; }
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[2197] | 93 | IVariable IModel.TargetVariable {
|
---|
| 94 | get { return this.TargetVariable; }
|
---|
| 95 | }
|
---|
| 96 |
|
---|
[2371] | 97 | private string modelType;
|
---|
| 98 | [Column(Storage = "modelType", CanBeNull = false)]
|
---|
| 99 | public string ModelType {
|
---|
| 100 | get { return this.modelType; }
|
---|
| 101 | private set { this.modelType = value; }
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | ModelType IModel.ModelType {
|
---|
| 105 | get {
|
---|
| 106 | if (!Enum.IsDefined(typeof(ModelType), this.modelType))
|
---|
| 107 | throw new ArgumentException("ModelType " + modelType + " not declared.");
|
---|
| 108 | return (ModelType)Enum.Parse(typeof(ModelType), this.modelType);
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 |
|
---|
[2326] | 112 | private string name;
|
---|
| 113 | [Column(Storage = "name", CanBeNull = true)]
|
---|
| 114 | public string Name {
|
---|
| 115 | get { return this.name; }
|
---|
| 116 | set { this.name = value; }
|
---|
| 117 | }
|
---|
| 118 |
|
---|
[2185] | 119 | private int trainingSamplesStart;
|
---|
| 120 | [Column(Storage = "trainingSamplesStart", CanBeNull = false)]
|
---|
| 121 | public int TrainingSamplesStart {
|
---|
| 122 | get { return this.trainingSamplesStart; }
|
---|
| 123 | set { this.trainingSamplesStart = value; }
|
---|
[2180] | 124 | }
|
---|
| 125 |
|
---|
[2185] | 126 | private int trainingSamplesEnd;
|
---|
| 127 | [Column(Storage = "trainingSamplesEnd", CanBeNull = false)]
|
---|
| 128 | public int TrainingSamplesEnd {
|
---|
| 129 | get { return this.trainingSamplesEnd; }
|
---|
| 130 | set { this.trainingSamplesEnd = value; }
|
---|
[2180] | 131 | }
|
---|
[2185] | 132 |
|
---|
| 133 | private int validationSamplesStart;
|
---|
| 134 | [Column(Storage = "validationSamplesStart", CanBeNull = false)]
|
---|
| 135 | public int ValidationSamplesStart {
|
---|
| 136 | get { return this.validationSamplesStart; }
|
---|
| 137 | set { this.validationSamplesStart = value; }
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | private int validationSamplesEnd;
|
---|
| 141 | [Column(Storage = "validationSamplesEnd", CanBeNull = false)]
|
---|
| 142 | public int ValidationSamplesEnd {
|
---|
| 143 | get { return this.validationSamplesEnd; }
|
---|
| 144 | set { this.validationSamplesEnd = value; }
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | private int testSamplesStart;
|
---|
| 148 | [Column(Storage = "testSamplesStart", CanBeNull = false)]
|
---|
| 149 | public int TestSamplesStart {
|
---|
| 150 | get { return this.testSamplesStart; }
|
---|
| 151 | set { this.testSamplesStart = value; }
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | private int testSamplesEnd;
|
---|
| 155 | [Column(Storage = "testSamplesEnd", CanBeNull = false)]
|
---|
| 156 | public int TestSamplesEnd {
|
---|
| 157 | get { return this.testSamplesEnd; }
|
---|
| 158 | set { this.testSamplesEnd = value; }
|
---|
| 159 | }
|
---|
[2180] | 160 | }
|
---|
| 161 | }
|
---|