Skip to content

Error thrown on simple equation #3

Open
@victorBaro

Description

@victorBaro

Thanks for this library, is working really well in many cases.

I am facing an issue though with a specific case:

        let solver: Solver = Solver()
        
        let row0 = Variable("row_0")
        let row1 = Variable("row_1")
        let row2 = Variable("row_2")
        let row3 = Variable("row_3")

        do {
            try solver.add(constraint: row0 == row1)
            try solver.add(constraint: row2 == row3)
            try solver.add(constraint: row0 + row1 + row2 + row3 == 240)
            try solver.add(constraint: row0 + row1 == 120)
            try solver.add(constraint: row2 + row3 == 120)
        } catch {
            throw error
        }

This simple equation is raising an error: caught error: "unable to satisfy constraint: 1.0 * row_2 + 1.0 * row_3 + -120.0 == 0

If I set any of the last 3 constraints as .strong (instead of required), the solver is able to resolve (all variable values are 60).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions