Code Monkey home page Code Monkey logo

Comments (10)

starwing avatar starwing commented on August 20, 2024 1

Very very thank you for your support :-)

from amoeba.

hfossli avatar hfossli commented on August 20, 2024

You see I'm considering writing a Swift wrapper and this seems to be my biggest concern so far.

from amoeba.

starwing avatar starwing commented on August 20, 2024

the assert() means never raise error, if assert() occurs, it's the coding bug and not a programming runtime error. any assertion failure should not occurs in production scene.

I have added auto test and coverage test, it's not 100%, that's the way I will work. for now in coverage amoeba should never crash on any input data.

from amoeba.

hfossli avatar hfossli commented on August 20, 2024

Great!

from amoeba.

hfossli avatar hfossli commented on August 20, 2024

Overconstraining a variable fails with

Assertion failed: (exit.id != 0), function am_remove, file ./amoeba.h, line 963.

Example code

static void test_twice(void) {
    am_Solver *s7 = am_newsolver(debug_allocf, NULL);
    am_Constraint *c15 = am_newconstraint(s7, 1000000000.0);
    am_setstrength(c15, 1000000000.0);
    am_setrelation(c15, 2);
    am_Variable *v14 = am_newvariable(s7);
    am_addterm(c15, v14, 1.0);
    am_addconstant(c15, -10.0);
    am_add(c15);
    am_Constraint *c16 = am_newconstraint(s7, 1000000000.0);
    am_setstrength(c16, 1000000000.0);
    am_setrelation(c16, 2);
    am_addterm(c16, v14, 1.0);
    am_addconstant(c16, -10.0);
    am_add(c16);
}

It seems better if it instead

  • returns a proper error code e.g. AM_FAILED
  • leaves the solver as if am_add(c16) didn't happen at all

from amoeba.

starwing avatar starwing commented on August 20, 2024

I will test it.

from amoeba.

starwing avatar starwing commented on August 20, 2024

to add a new constraint, we have several ways to try (via Cassowary algorithm):

  1. add it directly, if we find a subject.
  2. use a artificial variable to add.

if we cannot find a subject and all terms are dummy variable, and constant is not zero (means some constraint like x >= 10 when x <= 0), it's unsatisfied.

then, if we can not add it with a artificial variable, the constraint may unbound.

but, all other implements just throw errors in all these situations, I just try to restore the state of solver and return the proper error code. So I must remove the added constraint if needed, I need may test case on adding, because all other implement not do this.

If I'm not real add the constraint into solver and I try to remove it, this assertion failure will trigger, this is the source of this failure. I will improve it, but I need more test case to fix every the one case.

from amoeba.

hfossli avatar hfossli commented on August 20, 2024

I just try to restore the state of solver and return the proper error code

Music to my ears!

I will improve it

Fantastic!

but I need more test case to fix every the one case

I can create more test cases. The test_twice test was created using my swift wrapper. I can enable logging of all actions to the c-api of amoeba so that it is easy to reproduce any errors I get. That's why the solver is named s7 :)

Your library is very easy to use. Your style of writing c code is very clean. I'm very impressed with your skills!

from amoeba.

starwing avatar starwing commented on August 20, 2024

I have fixed this assertion failure, you could try the latest version.

from amoeba.

hfossli avatar hfossli commented on August 20, 2024

Perfect!

from amoeba.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.