43 #ifndef SHARK_MODELS_PROJECTBUDGETMAINTENANCESTRATEGY_H 44 #define SHARK_MODELS_PROJECTBUDGETMAINTENANCESTRATEGY_H 47 #include <shark/ObjectiveFunctions/KernelBasisDistance.h> 62 template<
class InputType>
66 typedef typename DataType::element_type
ElementType;
83 virtual void addToModel (ModelType& model,
InputType const& alpha, ElementType
const& supportVector) {
90 {
return "ProjectBudgetMaintenanceStrategy"; }
108 typedef typename DataType::element_type ElementType;
127 virtual void addToModel (ModelType& model, InputType
const& alpha, ElementType
const& supportVector) {
135 model.
basis().
element(maxIndex - 1) = supportVector.input;
136 row (model.
alpha(), maxIndex - 1) = alpha;
139 size_t firstIndex = 0;
140 double firstAlpha = 0;
145 if (firstAlpha == 0.0f)
149 model.
basis().
element(firstIndex) = supportVector.input;
150 row (model.
alpha(), firstIndex) = alpha;
153 row (model.
alpha(), maxIndex - 1).clear();
167 std::vector<RealVector> singlePointVector (1,model.
basis().
element(firstIndex));
168 std::vector<unsigned int> singlePointLabel (1, 0);
171 row (singlePointExpansion.alpha(), 0) = row (model.
alpha(), firstIndex);
172 KernelBasisDistance distance(&singlePointExpansion, maxIndex - 1);
179 RealVector point(inputDimension * (maxIndex - 1));
182 size_t linearIndex = 0;
183 for(std::size_t t = 0; t < maxIndex; t++){
187 noalias(subrange(point, linearIndex*inputDimension, (linearIndex+1)*inputDimension)) = (model.
basis().
element(t));
192 RealMatrix projectedAlphas = distance.findOptimalBeta(point);
199 for (std::size_t j = 0; j < maxIndex; j++)
205 for (std::size_t c = 0; c < model.
alpha().size2(); c++)
206 model.
alpha(j, c) += projectedAlphas(linearIndex, c);
212 model.
basis().
element(firstIndex) = supportVector.input;
213 row (model.
alpha(), firstIndex) = alpha;
216 row (model.
alpha(), maxIndex - 1).clear();
222 {
return "ProjectBudgetMaintenanceStrategy"; }