-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbbb-relax.js
33 lines (29 loc) · 1016 Bytes
/
bbb-relax.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {default as PlainRelax, RelaxNode} from '../relax/relax.js';
import ConstraintInterpreter from './constraintinterpreter.js';
import {newUUID} from './util.js';
// Babelsberg required interface
// addConstraint, removeConstraint
export default class Relax extends PlainRelax {
always(opts, func) {
if (opts.priority) {
throw 'soft constraints not implemented for relax';
}
func.varMapping = opts.ctx;
var constraint = ConstraintInterpreter.newConstraint(func, this);
this.addConstraint(constraint.constraintobjects[0]);
//this.solve();
return constraint;
}
constraintVariableFor(value, ivarname) {
if ((typeof(value) == 'number') ||
(value === null) ||
(value instanceof Number)) {
var name = ivarname + ':' + newUUID();
var v = new RelaxNode('vars[\"' + name + '\"]', [name], this);
this.addVar(name, value);
return v;
} else {
return null;
}
}
}