consys-solver
Version:
consys-solver is a tool to find feasible model assignments for consys constraint systems.
33 lines (32 loc) • 1.1 kB
TypeScript
/**
* Maps values of a domain to a weight between 0 and 10. Higher weights make it
* more likely for the value to be chosen by the solver.
*/
export declare type PreferenceFunction<T> = (value: T) => number;
/**
* Represents an abstract domain for the solver.
*/
export default abstract class Domain<T> {
static readonly maxPreference = 10;
readonly kind: string;
protected valuePreference: (value: T) => number;
/**
* Creates an abstract domain with a preference function. This function
* associates weights from 0 to 10 for each value in the domain. Higher
* preference weights mean that the value is more likely to be chosen.
*
* @param valuePreference preference function
* @protected
*/
protected constructor(valuePreference?: PreferenceFunction<T>);
/**
* Returns the preference value for a particular element.
*
* @param element element
*/
getPreferenceValue(element: T): number;
/**
* Should return all values of the domain. The order is irrelevant.
*/
abstract getValues(): T[];
}