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
+34
View File
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>afryca.behavior.standard</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;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
@@ -0,0 +1,9 @@
#Properties file for afryca.behavior.standard
afryca.behavior.standard.description = Standard behavior
afryca.behavior.standard.name = Standard
afryca.behavior.standard.parameter.p.description = Probability of accepting a change recommendation
afryca.behavior.standard.parameter.mu.description = Average degree of change on an assessment
afryca.behavior.standard.parameter.size.description = Range of possible degrees of change around the average
afryca.behavior.standard.parameter.fix.description = Fix degree of change (set with mu parameter) when the value is 1
Bundle-Vendor = Sinbad\u00B2
Bundle-Name = Standard behavior
@@ -0,0 +1,9 @@
#Archivo de propiedades para afryca.behavior.standard
afryca.behavior.standard.description = Comportamiento estándar
afryca.behavior.standard.name = Estándar
afryca.behavior.standard.parameter.p.description = Probabilidad de aceptar una recomendación de cambiar
afryca.behavior.standard.parameter.mu.description = Grado medio de cambio en una valoración
afryca.behavior.standard.parameter.size.description = Rango de posibles grados de cambio alrededor de la media
afryca.behavior.standard.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 = Comportamiento estándar
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
OSGI-INF/
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="afryca.behavior">
<Behavior
Behavior="afryca.behavior.Standard"
description="%afryca.behavior.standard.description "
id="afryca.behavior.standard"
name="%afryca.behavior.standard.name">
<Parameter
default_value="0.5"
description="%afryca.behavior.standard.parameter.p.description"
id="p"
lower_limit="0"
type="Float"
upper_limit="1">
</Parameter>
<Parameter
default_value="0.05"
description="%afryca.behavior.standard.parameter.mu.description"
id="mu"
lower_limit="0"
type="Float"
upper_limit="1">
</Parameter>
<Parameter
default_value="0.2"
description="%afryca.behavior.standard.parameter.size.description"
id="size"
lower_limit="0"
type="Float">
</Parameter>
<Parameter
default_value="0"
description="%afryca.behavior.standard.parameter.fix.description"
id="fix"
lower_limit="0"
type="Integer"
upper_limit="1">
</Parameter>
</Behavior>
</extension>
</plugin>
@@ -0,0 +1,128 @@
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 behavior
*
* @author Sinbad²
* @version 3.0
*/
public class Standard extends Behavior {
public static final String ID = "afryca.behavior.standard"; //$NON-NLS-1$
private static final float ACCEPT_CHANGE = 1f;
public static final String P = "p"; //$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(MU)
private float mu;
@Inject
@Optional
@Named(SIZE)
private float size;
@Inject
@Optional
@Named(FIX)
private int fix;
private float normalizedMu;
private float normalizedSize;
private float upperLimit;
@Override
public double[] getNChanges(int numberOfChanges) {
normalizeParameters();
double[] behaviorsTowardChange = getBehaviorsTowardChange(numberOfChanges);
double[] changes = getChanges(behaviorsTowardChange);
return assignChangesBasedOnAttitude(behaviorsTowardChange, changes);
}
private void normalizeParameters() {
normalizedMu = mu * 100f;
normalizedSize = size * 100f;
upperLimit = normalizedMu + (normalizedSize / 2f);
if (upperLimit > 100f) {
upperLimit = 100f;
}
}
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[] getChanges(double[] behaviorsTowardChange) {
if(fix == 0) {
return getNChangesFromCache(
"rnbinom(" + normalizedMu + "," + normalizedSize + ")", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
(int) Arrays
.stream(behaviorsTowardChange)
.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(behaviorsTowardChange).filter(this::accept).count()];
for(int c = 0; c < changes.length; c++) {
changes[c] = normalizedMu;
}
return changes;
}
}
private boolean accept(double attitude) {
return (attitude == ACCEPT_CHANGE);
}
private double[] assignChangesBasedOnAttitude(double[] attitudes, double[] changes) {
OfDouble iterator = Arrays.stream(changes).iterator();
return Arrays
.stream(attitudes)
.map(attitude -> (attitude == ACCEPT_CHANGE)
? adjustChange(iterator.next())
: 0f)
.toArray();
}
private double adjustChange(double change) {
return enforceValueRange(change, normalizedMu, upperLimit) / 100f;
}
}
@@ -0,0 +1,11 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: afryca.behavior.standard;singleton:=true
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
@@ -0,0 +1,4 @@
#Fri Jan 22 13:00:43 CET 2021
artifact.main=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.behavior.standard\\target\\afryca.behavior.standard-1.0.0-SNAPSHOT.jar
artifact.attached.p2artifacts=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.behavior.standard\\target\\p2artifacts.xml
artifact.attached.p2metadata=C\:\\Users\\\u00C1lvaro\\Workspaces\\afryca_2020\\afryca\\plugins\\afryca.behavior.standard\\target\\p2content.xml
@@ -0,0 +1,3 @@
artifactId=afryca.behavior.standard
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' version='1.0.0.202101221157'>
<properties size='5'>
<property name='artifact.size' value='6083'/>
<property name='download.size' value='6083'/>
<property name='maven-groupId' value='afryca.group'/>
<property name='maven-artifactId' value='afryca.behavior.standard'/>
<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' version='1.0.0.202101221157' generation='2'>
<update id='afryca.behavior.standard' range='[0.0.0,1.0.0.202101221157)' severity='0'/>
<properties size='9'>
<property name='es.Bundle-Name' value='Comportamiento estándar'/>
<property name='es.Bundle-Vendor' value='Sinbad²'/>
<property name='df_LT.Bundle-Name' value='Standard behavior'/>
<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'/>
<property name='maven-version' value='1.0.0-SNAPSHOT'/>
</properties>
<provides size='6'>
<provided namespace='org.eclipse.equinox.p2.iu' name='afryca.behavior.standard' version='1.0.0.202101221157'/>
<provided namespace='osgi.bundle' name='afryca.behavior.standard' version='1.0.0.202101221157'/>
<provided namespace='osgi.identity' name='afryca.behavior.standard' 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
</description>
</requiredProperties>
</requires>
<artifacts size='1'>
<artifact classifier='osgi.bundle' id='afryca.behavior.standard' 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;singleton:=true&#xA;Bundle-Version: 1.0.0.202101221157&#xA;
</instruction>
</instructions>
</touchpointData>
</unit>
</units>