Commit 39987bfa authored by Nicola Gatto's avatar Nicola Gatto
Browse files

Rename cocos check

parent e3b5108d
......@@ -26,24 +26,23 @@ import de.monticore.lang.monticar.cnntrain._ast.ASTRLAlgorithmEntry;
import de.monticore.lang.monticar.cnntrain.helper.ErrorCodes;
import de.se_rwth.commons.logging.Log;
public class CheckDdpgRequiresCriticNetwork implements CNNTrainASTConfigurationCoCo {
import static de.monticore.lang.monticar.cnntrain._cocos.ASTConfigurationUtils.hasCriticEntry;
import static de.monticore.lang.monticar.cnntrain._cocos.ASTConfigurationUtils.isActorCriticAlgorithm;
public class CheckActorCriticRequiresCriticNetwork implements CNNTrainASTConfigurationCoCo {
@Override
public void check(ASTConfiguration node) {
boolean isDdpg = node.getEntriesList().stream()
.anyMatch(e -> e instanceof ASTRLAlgorithmEntry
&& ((ASTRLAlgorithmEntry)e).getValue().isPresentDdpg());
boolean hasCriticEntry = node.getEntriesList().stream()
.anyMatch(e -> ((e instanceof ASTCriticNetworkEntry)
&& !((ASTCriticNetworkEntry)e).getValue().getNameList().isEmpty()));
boolean isActorCritic = isActorCriticAlgorithm(node);
boolean hasCriticEntry = hasCriticEntry(node);
if (isDdpg && !hasCriticEntry) {
if (isActorCritic && !hasCriticEntry) {
ASTRLAlgorithmEntry algorithmEntry = node.getEntriesList().stream()
.filter(e -> e instanceof ASTRLAlgorithmEntry)
.map(e -> (ASTRLAlgorithmEntry)e)
.findFirst()
.orElseThrow(() -> new IllegalStateException("ASTRLAlgorithmEntry entry must be available"));
Log.error("0" + ErrorCodes.REQUIRED_PARAMETER_MISSING + " DDPG learning algorithm requires critc" +
Log.error("0" + ErrorCodes.REQUIRED_PARAMETER_MISSING + " DDPG learning algorithm requires critic" +
" network entry", algorithmEntry.get_SourcePositionStart());
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment