UNPKG

consys-solver

Version:

consys-solver is a tool to find feasible model assignments for consys constraint systems.

32 lines (31 loc) 974 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Represents an abstract domain for the solver. */ class Domain { /** * 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 */ constructor(valuePreference = () => 1) { // internally used to determine the type this.kind = 'Domain'; this.valuePreference = valuePreference; } /** * Returns the preference value for a particular element. * * @param element element */ getPreferenceValue(element) { return Math.max(0, Math.min(this.valuePreference(element), Domain.maxPreference)); } } exports.default = Domain; // maximum preference value Domain.maxPreference = 10;