File size: 4,939 Bytes
5070096 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
standard library package TradeStudies {
doc
/*
* This package provides a simple framework for defining trade-off study analysis cases.
*/
private import Base::Anything;
private import ScalarValues::*;
private import ScalarFunctions::*;
private import ControlFunctions::*;
abstract calc def EvaluationFunction {
doc
/*
* An EvaluationFunction is a calculation that evaluates a TradeStudy alternative,
* producing a ScalarValue that can be comparted with the evaluation of other
* alternatives.
*/
in ref alternative : Anything {
doc
/*
* The alternative to be evaluated.
*/
}
return attribute result : ScalarValue[1] {
doc
/*
* A ScalarValue representing the evaluation of the given alternative.
*/
}
}
abstract requirement def TradeStudyObjective {
doc
/*
* A TradeStudyObjective is the base definition for the objective of a TradeStudy.
* The requirement is to choose from a given set of alternatives the selectedAlternative
* for that has the best evaluation according to a given EvaluationFunction. What
* value is considered "best" is not defined in the abstract base definition but must be
* computed in any concrete specialization.
*/
subject selectedAlternative : Anything {
doc
/*
* The alternative that should be selected, as evaluated using the given
* ObjectiveFunction.
*/
}
in ref alternatives : Anything[1..*] {
doc
/*
* The alternatives being considered in the TradeStudy for which this TradeStudyObjective
* is the objective.
*/
}
in calc fn : EvaluationFunction {
doc
/*
* The EvaluationFunction to be used in evaluating the given alternatives.
*/
}
out attribute best : ScalarValue {
doc
/*
* Out of the evaluation results of all the given alternatives, the one that is considered
* "best", in the sense that it is the value the selectedAlternative should have. This
* value must be computed in any concrete specialization of TradeStudyObjective.
*/
}
require constraint { fn(selectedAlternative) == best }
}
requirement def MinimizeObjective :> TradeStudyObjective {
doc
/*
* A MinimizeObjective is a TradeStudyObjective that requires that the
* selectedAlternative have the minimum ObjectiveFunction value of all the
* given alternatives.
*/
subject :>> selectedAlternative;
in ref :>> alternatives;
in calc :>>fn;
out attribute :>> best = alternatives->minimize {
doc
/*
* For a MinimizeObjective, the best value is the minimum one.
*/
in x; fn(x)
};
}
requirement def MaximizeObjective :> TradeStudyObjective {
doc
/*
* A MaximizeObjective is a TradeStudyObjective that requires that the
* selectedAlternative have the maximum ObjectiveFunction value of all the
* given alternatives.
*/
subject :>> selectedAlternative;
in ref :>> alternatives;
in calc :>>fn;
out attribute :>> best = alternatives->maximize {
doc
/*
* For a MinimizeObjective, the best value is the maximum one.
*/
in x; fn(x)
};
}
abstract analysis def TradeStudy {
doc
/*
* A TradeStudy is an analysis case whose subject is a set of alternatives
* (at least one) and whose result is a selection of one of those alternatives.
* The alternatives are evaluated based on a given ObjectiveFunction and the
* selection is made such that it satisfies the objective of the TradeStudy
* (which must be a TradeStudyObjective).
*/
subject studyAlternatives : Anything[1..*] {
doc
/*
* The set of alternatives being considered in this TradeStudy.
*
* In a TradeStudy usage, bind this feature to the actual collection of
* alternatives to be considered.
*/
}
abstract calc evaluationFunction : EvaluationFunction {
doc
/*
* The EvaluationFunction to be used to evaluate the alternatives.
*
* In a TradeStudy usage, redefine this feature to provide the desired
* calculation (or bind it to a calculation usage that does so).
*/
}
objective tradeStudyObjective : TradeStudyObjective {
doc
/*
* The objective of this TradeStudy.
*
* Redefine this feature to give it a definition that is a concrete
* specialization of TradeStudyObjective. That can either be one of the
* specializations provided in this package, or a more specific user-
* defined one.
*/
subject :>> selectedAlternative;
in ref :>> alternatives = studyAlternatives;
in calc :>> fn = evaluationFunction;
}
return selectedAlternative : Anything = studyAlternatives->selectOne {in ref a {
doc
/*
* The alternative selected by this TradeStudy, which is the one that meets the
* requirement of the tradeStudyObjective.
*/
} tradeStudyObjective(selectedAlternative = a)};
}
} |