public code v1

This commit is contained in:
2026-05-22 11:14:29 +02:00
parent 427197ec5a
commit b8141736eb
28859 changed files with 575079 additions and 0 deletions
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -0,0 +1 @@
/bin
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>afryca.behavior.standard_with_adverse</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
line.separator=\n
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: afryca.behavior.standard_with_adverse;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: afryca.behavior,
afryca.ase,
javax.inject,
org.eclipse.core.runtime,
org.eclipse.e4.core.di
Automatic-Module-Name: afryca.behavior.standard_with_adverse
@@ -0,0 +1,10 @@
#Properties file for afryca.behavior.standard_with_adverse
afryca.behavior.standard-with-adverse.description = Standard behavior with adverse
afryca.behavior.standard-with-adverse.name = Standard with adverse
afryca.behavior.standard-with-adverse.parameter.p.description = Probability of accepting a change recommendation
afryca.behavior.standard-with-adverse.parameter.c.description = Probability of adverse behavior when receiving a advise
afryca.behavior.standard-with-adverse.parameter.mu.description = Average degree of change on an assessment
afryca.behavior.standard-with-adverse.parameter.size.description = Range of possible degrees of change around the average
afryca.behavior.standard-with-adverse.parameter.fix.description = Fix degree of change (set with mu parameter) when the value is 1
Bundle-Vendor = Sinbad\u00B2
Bundle-Name = Standard with adverse
@@ -0,0 +1,10 @@
#Archivo de propiedades para afryca.behavior.standard_with_adverse
afryca.behavior.standard-with-adverse.description = Comportamiento estándar con adverso
afryca.behavior.standard-with-adverse.name = Estándar con adverso
afryca.behavior.standard-with-adverse.parameter.p.description = Probabilidad de aceptar una recomendación de cambiar
afryca.behavior.standard-with-adverse.parameter.c.description = Probabilidad de un comportamiento adverso al recibir una recomendación
afryca.behavior.standard-with-adverse.parameter.mu.description = Grado medio de cambio en una valoración
afryca.behavior.standard-with-adverse.parameter.size.description = Rango de posibles grados de cambio alrededor de la media
afryca.behavior.standard-with-adverse.parameter.fix.description = Fija el grado de cambio (asignar con el parámetro mu) cuando el valor es 1
Bundle-Vendor = Sinbad\u00B2
Bundle-Name = Standard with adverse
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
OSGI-INF/
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="afryca.behavior">
<Behavior
Behavior="afryca.behavior.StandardWithAdverse"
description="%afryca.behavior.standard-with-adverse.description"
id="afryca.behavior.standard_with_adverse"
name="%afryca.behavior.standard-with-adverse.name">
<Parameter
default_value="0.5"
description="%afryca.behavior.standard-with-adverse.parameter.p.description"
id="p"
lower_limit="0"
type="Float"
upper_limit="1">
</Parameter>
<Parameter
default_value="0.25"
description="%afryca.behavior.standard-with-adverse.parameter.c.description"
id="c"
lower_limit="0"
type="Float"
upper_limit="1">
</Parameter>
<Parameter
default_value="0.05"
description="%afryca.behavior.standard-with-adverse.parameter.mu.description"
id="mu"
lower_limit="0"
type="Float"
upper_limit="1">
</Parameter>
<Parameter
default_value="0.2"
description="%afryca.behavior.standard-with-adverse.parameter.size.description"
id="size"
lower_limit="0"
type="Float">
</Parameter>
<Parameter
default_value="0"
description="%afryca.behavior.standard-with-adverse.parameter.fix.description"
id="fix"
lower_limit="0"
type="Integer"
upper_limit="1">
</Parameter>
</Behavior>
</extension>
</plugin>
@@ -0,0 +1,182 @@
package afryca.behavior;
import java.util.Arrays;
import java.util.PrimitiveIterator.OfDouble;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.Optional;
/**
* Standard with adverse behavior
*
* @author Sinbad²
* @version 3.0
*/
public class StandardWithAdverse extends Behavior {
public static final String ID = "afryca.behavior.standard_with_adverse"; //$NON-NLS-1$
private static final float ACCEPT_CHANGE = 1f;
private static final int NEUTRAL_ATTITUDE = 0;
private static final int FAVORABLE_ATTITUDE = 1;
private static final int ADVERSE_ATTITUDE = -FAVORABLE_ATTITUDE;
public static final String P = "p"; //$NON-NLS-1$
public static final String C = "c"; //$NON-NLS-1$
public static final String MU = "mu"; //$NON-NLS-1$
public static final String SIZE = "size"; //$NON-NLS-1$
public static final String FIX = "fix"; //$NON-NLS-1$
@Inject
@Optional
@Named(P)
private float p;
@Inject
@Optional
@Named(C)
private float c;
@Inject
@Optional
@Named(MU)
private float mu;
@Inject
@Optional
@Named(SIZE)
private float size;
@Inject
@Optional
@Named(FIX)
private float fix;
private float normalizedMu;
private float normalizedSize;
private float upperLimit;
@Override
public double[] getNChanges(int numberOfChanges) {
normalizeParameters();
double[] behaviorsTowardChange = getBehaviorsTowardChange(numberOfChanges);
double[] behaviorsTowardAdverseChange = getBehaviorsTowardAdverseChange(behaviorsTowardChange);
double[] favorableChanges = getChanges(behaviorsTowardChange);
double[] adverseChanges = getChanges(behaviorsTowardAdverseChange);
int[] attitudes = computeAttitudes(behaviorsTowardChange, behaviorsTowardAdverseChange);
return assignChangesBasedOnAttitudes(attitudes, favorableChanges, adverseChanges);
}
private double[] getBehaviorsTowardChange(int numberOfChanges) {
return getNChangesFromCache(
"rbinom(1," + p + ")", //$NON-NLS-1$ //$NON-NLS-2$
numberOfChanges,
(n) -> (Double[]) aseService
.createFragmentBuilder()
.putVariable("n", n) //$NON-NLS-1$
.putVariable("size", 1) //$NON-NLS-1$
.putVariable("probability", p) //$NON-NLS-1$
.setCode("behavior.rbinom(n, size, probability)") //$NON-NLS-1$
.setOutputType("java.lang.Double[]") //$NON-NLS-1$
.eval()
.getResult());
}
private double[] getBehaviorsTowardAdverseChange(double[] behaviorsTowardChange) {
return getNChangesFromCache(
"rbinom(1," + c + ")", //$NON-NLS-1$ //$NON-NLS-2$
behaviorsTowardChange.length - (int) Arrays.stream(behaviorsTowardChange).filter(this::accept).count(),
(n) -> (Double[]) aseService
.createFragmentBuilder()
.putVariable("n", n) //$NON-NLS-1$
.putVariable("size", 1) //$NON-NLS-1$
.putVariable("probability", c) //$NON-NLS-1$
.setCode("behavior.rbinom(n, size, probability)") //$NON-NLS-1$
.setOutputType("java.lang.Double[]") //$NON-NLS-1$
.eval()
.getResult());
}
private boolean accept(double attitude) {
return (attitude == ACCEPT_CHANGE);
}
private int[] computeAttitudes(double[] favorable, double[] notFavorable) {
OfDouble iterator = Arrays.stream(notFavorable).iterator();
return Arrays
.stream(favorable)
.mapToInt(attitude -> computeAttitude(attitude, iterator))
.toArray();
}
private int computeAttitude(double favorableAttitude, OfDouble iteratorOfAdverseAttitudes) {
return (favorableAttitude == ACCEPT_CHANGE)
? FAVORABLE_ATTITUDE
: ((iteratorOfAdverseAttitudes.next() == ACCEPT_CHANGE)
? ADVERSE_ATTITUDE
: NEUTRAL_ATTITUDE);
}
private double[] getChanges(double[] behaviors) {
if(fix == 0) {
return getNChangesFromCache(
"rnbinom(" + normalizedMu + "," + normalizedSize + ")", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
(int) Arrays
.stream(behaviors)
.filter(this::accept)
.count(),
(n) -> (Double[]) aseService
.createFragmentBuilder()
.putVariable("n", n) //$NON-NLS-1$
.putVariable("mu", normalizedMu) //$NON-NLS-1$
.putVariable("size", normalizedSize) //$NON-NLS-1$
.setCode("behavior.rnbinom(n, mu, size)") //$NON-NLS-1$
.setOutputType("java.lang.Double[]") //$NON-NLS-1$
.eval()
.getResult());
} else {
double[] changes = new double[(int) Arrays.stream(behaviors).filter(this::accept).count()];
for(int c = 0; c < changes.length; c++) {
changes[c] = normalizedMu;
}
return changes;
}
}
private double[] assignChangesBasedOnAttitudes(int[] attitudes, double[] favorable, double[] notFavorable) {
OfDouble favorableIterator = Arrays.stream(favorable).iterator();
OfDouble notFavorableIterator = Arrays.stream(notFavorable).iterator();
return Arrays
.stream(attitudes)
.mapToDouble(attitude -> computeChange(attitude, favorableIterator, notFavorableIterator))
.toArray();
}
private double computeChange(
int attitude,
OfDouble iteratorOfFavorableChanges,
OfDouble iteratorOfNotFavorableChanges) {
switch (attitude) {
case FAVORABLE_ATTITUDE:
return iteratorOfFavorableChanges.next() / 100d;
case ADVERSE_ATTITUDE:
return -(iteratorOfNotFavorableChanges.next() / 100d);
default:
return 0;
}
}
private void normalizeParameters() {
normalizedMu = mu * 100f;
normalizedSize = size * 100f;
upperLimit = normalizedMu + (normalizedSize / 2f);
if (upperLimit > 100f) {
upperLimit = 100f;
}
}
}
@@ -0,0 +1,12 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: afryca.behavior.standard_with_adverse;singleton:=tr
ue
Bundle-Version: 1.0.0.202101221157
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: afryca.behavior,afryca.ase,javax.inject,org.eclipse.core
.runtime,org.eclipse.e4.core.di
Automatic-Module-Name: afryca.behavior.standard_with_adverse
@@ -0,0 +1,4 @@
#Fri Jan 22 13:00:44 CET 2021
artifact.main=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.behavior.standard_with_adverse\\target\\afryca.behavior.standard_with_adverse-1.0.0-SNAPSHOT.jar
artifact.attached.p2artifacts=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.behavior.standard_with_adverse\\target\\p2artifacts.xml
artifact.attached.p2metadata=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.behavior.standard_with_adverse\\target\\p2content.xml
@@ -0,0 +1,3 @@
artifactId=afryca.behavior.standard_with_adverse
groupId=afryca.group
version=1.0.0-SNAPSHOT
@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<?artifactRepository version='1.1.0'?>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='afryca.behavior.standard_with_adverse' version='1.0.0.202101221157'>
<properties size='5'>
<property name='artifact.size' value='7068'/>
<property name='download.size' value='7068'/>
<property name='maven-groupId' value='afryca.group'/>
<property name='maven-artifactId' value='afryca.behavior.standard_with_adverse'/>
<property name='maven-version' value='1.0.0-SNAPSHOT'/>
</properties>
</artifact>
</artifacts>
@@ -0,0 +1,52 @@
<?xml version='1.0' encoding='UTF-8'?>
<units size='1'>
<unit id='afryca.behavior.standard_with_adverse' version='1.0.0.202101221157' generation='2'>
<update id='afryca.behavior.standard_with_adverse' range='[0.0.0,1.0.0.202101221157)' severity='0'/>
<properties size='9'>
<property name='es.Bundle-Name' value='Standard with adverse'/>
<property name='es.Bundle-Vendor' value='Sinbad²'/>
<property name='df_LT.Bundle-Name' value='Standard with adverse'/>
<property name='df_LT.Bundle-Vendor' value='Sinbad²'/>
<property name='org.eclipse.equinox.p2.name' value='%Bundle-Name'/>
<property name='org.eclipse.equinox.p2.provider' value='%Bundle-Vendor'/>
<property name='maven-groupId' value='afryca.group'/>
<property name='maven-artifactId' value='afryca.behavior.standard_with_adverse'/>
<property name='maven-version' value='1.0.0-SNAPSHOT'/>
</properties>
<provides size='6'>
<provided namespace='org.eclipse.equinox.p2.iu' name='afryca.behavior.standard_with_adverse' version='1.0.0.202101221157'/>
<provided namespace='osgi.bundle' name='afryca.behavior.standard_with_adverse' version='1.0.0.202101221157'/>
<provided namespace='osgi.identity' name='afryca.behavior.standard_with_adverse' version='1.0.0.202101221157'>
<properties size='1'>
<property name='type' value='osgi.bundle'/>
</properties>
</provided>
<provided namespace='org.eclipse.equinox.p2.eclipse.type' name='bundle' version='1.0.0'/>
<provided namespace='org.eclipse.equinox.p2.localization' name='es' version='1.0.0'/>
<provided namespace='org.eclipse.equinox.p2.localization' name='df_LT' version='1.0.0'/>
</provides>
<requires size='6'>
<required namespace='osgi.bundle' name='afryca.behavior' range='0.0.0'/>
<required namespace='osgi.bundle' name='afryca.ase' range='0.0.0'/>
<required namespace='osgi.bundle' name='javax.inject' range='0.0.0'/>
<required namespace='osgi.bundle' name='org.eclipse.core.runtime' range='0.0.0'/>
<required namespace='osgi.bundle' name='org.eclipse.e4.core.di' range='0.0.0'/>
<requiredProperties namespace='osgi.ee' match='(&amp;(osgi.ee=JavaSE)(version=1.8))'>
<description>
afryca.behavior.standard_with_adverse
</description>
</requiredProperties>
</requires>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='afryca.behavior.standard_with_adverse' version='1.0.0.202101221157'/>
</artifacts>
<touchpoint id='org.eclipse.equinox.p2.osgi' version='1.0.0'/>
<touchpointData size='1'>
<instructions size='1'>
<instruction key='manifest'>
Bundle-SymbolicName: afryca.behavior.standard_with_adverse;singleton:=true&#xA;Bundle-Version: 1.0.0.202101221157&#xA;
</instruction>
</instructions>
</touchpointData>
</unit>
</units>