@@ -0,0 +1,2245 @@
+/*******************************************************************************%0A * DIANNE  - Framework for distributed artificial neural networks%0A * Copyright (C) 2015  iMinds - IBCN - UGent%0A *%0A * This file is part of DIANNE.%0A *%0A * DIANNE is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as%0A * published by the Free Software Foundation, either version 3 of the%0A * License, or (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU Affero General Public License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A *%0A * Contributors:%0A *     Tim Verbelen, Steven Bohez%0A *******************************************************************************/%0Apackage be.iminds.iot.dianne.rl.experience.adapters;%0A%0Aimport java.util.Map;%0A%0Aimport org.osgi.service.component.annotations.Component;%0Aimport org.osgi.service.component.annotations.ConfigurationPolicy;%0A%0Aimport be.iminds.iot.dianne.api.dataset.Dataset;%0Aimport be.iminds.iot.dianne.api.rl.dataset.ExperiencePool;%0Aimport be.iminds.iot.dianne.api.rl.dataset.ExperiencePoolSample;%0Aimport be.iminds.iot.dianne.tensor.TensorOps;%0A%0A@Component(%0A%09%09service=%7BDataset.class, ExperiencePool.class%7D,%09%0A%09%09configurationPolicy=ConfigurationPolicy.REQUIRE,%0A%09%09configurationPid=%22be.iminds.iot.dianne.dataset.adapters.EnergyPenalizationAdapter%22)%0Apublic class EnergyPenalizationAdapter extends AbstractExperiencePoolAdapter %7B%0A%0A%09private float energyPenalization = 0.0f;%0A%09%0A%09@Override%0A%09protected void configure(Map%3CString, Object%3E properties) %7B%0A%09%09if(properties.containsKey(%22energyPenalization%22))%7B%0A%09%09%09this.energyPenalization = Float.parseFloat(properties.get(%22energyPenalization%22).toString());%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09protected void adaptFetchedSample(ExperiencePoolSample s) %7B%0A%09%09TensorOps.sub(s.reward, s.reward, energyPenalization*TensorOps.dot(s.target, s.target));%0A%09%7D%0A%0A%09@Override%0A%09protected void adaptAddingSample(ExperiencePoolSample s) %7B%0A%09%7D%0A%0A%0A%0A%7D%0A

add an EnergyPenalizationAdapter