public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -0,0 +1,70 @@
package flintstones.valuation.numeric;
import flintstones.helper.validator.Validator;
public abstract class NumericIntervalarValuation extends NumericValuation {
/** The min value. */
public double _min;
/** The max value. */
public double _max;
/**
* Sets the min.
*
* @param min the new min
*/
public void setMin(double min) {
this._min = min;
}
/**
* Gets the min.
*
* @return the min
*/
public double getMin() {
return this._min;
}
/**
* Sets the max.
*
* @param max the new max
*/
public void setMax(double max) {
this._max = max;
}
/**
* Gets the max.
*
* @return the max
*/
public double getMax() {
return this._max;
}
/**
* Sets the min max.
*
* @param min the min
* @param max the max
*/
public void setMinMax(Double min, Double max) {
Validator.notNull(this.domain);
Validator.notDisorder(new double[] { min, max }, false);
this._min = min;
this._max = max;
}
@Override
public NumericValuation cloneToNormalize() {
throw new Error("Interval valuation is not normalized");
}
}
@@ -0,0 +1,81 @@
package flintstones.valuation.numeric;
import flintstones.domain.numeric.NumericDomain;
import flintstones.entity.valuation.Valuation;
import flintstones.entity.valuation.exception.InvalidValueException;
import flintstones.helper.validator.Validator;
/**
* The Class NumericValuation.
*/
public abstract class NumericValuation extends Valuation {
/** The value. */
protected double value;
/**
* Normalized.
*
* @return the valuation
*/
public Valuation normalized() {
NumericValuation result = (NumericValuation) this.clone();
double min, max, intervalSize;
min = ((NumericDomain) this.domain).getMin();
max = ((NumericDomain) this.domain).getMax();
intervalSize = max - min;
((NumericDomain) result.domain).setMinMax(0d, 1d);
result.value = (this.value - min) / intervalSize;
return result;
}
/**
* Gets the value.
*
* @return the value
*/
public double getValue() {
return this.value;
}
/**
* Sets the value.
*
* @param value the new value
*/
public void setValue(double value) {
// 1 Check domain
if(domain == null)
throw new InvalidValueException("No exíste un dominio asignado");
NumericDomain cDomain = (NumericDomain) this.domain;
if (cDomain.getInRange()) {
double min = cDomain.getMin();
double max = cDomain.getMax();
boolean inRange = Validator.inRange(value, min, max);
// 2.Check range
if(!inRange)
throw new InvalidValueException("El valor " + value + " no se encuentra en el rango correcto " + min + "," + max);
this.value = value;
} else {
this.value = value;
}
};
/**
* Clone to normalize.
*
* @return the numeric valuation
*/
// This let us use Integer Valuation as Real in a copy. The domain is also patched into a real one.
public abstract NumericValuation cloneToNormalize();
}