computational-problem-solving/sat

View on GitHub
src/core/convert/SignsInstance.js

Summary

Maintainability
A
30 mins
Test Coverage
import _count from './_count.js';

/**
 * Allows to produce an assignment format that makes sense in sign format.
 */
export default class SignsInstance {
    /**
     * Clauses are in parity format.
     *
     * @param {number[][]} clauses The clauses in parity format.
     */
    constructor(clauses) {
        /** @member {number[][]} The clauses in parity format. */
        this.clauses = clauses;
        /** @member {number} The number of variables in this instance. */
        this.n = _count(clauses);
    }

    /**
     * Returns assignment vector in signs format.
     *
     * @param {number[]} certificate
     * @return {number[]}
     */
    assignment(certificate) {
        return [0].concat(certificate);
    }
}