Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable auto-selection of solver from SymPy passes #46

Closed
pramodk opened this issue Mar 9, 2019 · 0 comments · Fixed by #94
Closed

Disable auto-selection of solver from SymPy passes #46

pramodk opened this issue Mar 9, 2019 · 0 comments · Fixed by #94
Assignees
Labels
bug Something isn't working codegen Code generation backend
Milestone

Comments

@pramodk
Copy link
Contributor

pramodk commented Mar 9, 2019

Sympy pass should prefer the solve method specify by user in the MOD file. Currently if ODEs are linear then sympy doesn't use derivimplicit method specified by user.

In this case emit warning/info to user but use solve method specified in the MOD file.

@pramodk pramodk added bug Something isn't working codegen Code generation backend labels Mar 9, 2019
@pramodk pramodk added this to the v0.2 milestone Mar 9, 2019
@lkeegan lkeegan self-assigned this Mar 9, 2019
lkeegan added a commit that referenced this issue Mar 21, 2019
  - SympySolver visitor also visits LINEAR blocks now
  - For small systems, replaces eqs directly with solutions
  - For larger systems, replaces with matrix system to be solved (codegen required)
      * this change resolves #57 (numerical instability of sparse solver)
  - In both cases it inserts the equations in the right location in the statement block
      * this change partially resolves #55 (order of statements in DERIVATIVE block)
  - Add some unit tests

also
  - refactored solvers: KINETIC -> DERIVATIVE -> (NON_)LINEAR
      * first any KINETIC blocks are converted to DERIVATIVE blocks
      * then ODEs in DERIVATIVE blocks are converted to a system of (non)linear equations
      * these are then solved with the same solvers as LINEAR or NON_LINEAR blocks
      * reduces unnecessary duplication of functionality
      * this change resolves #46 (sympy solver ignoring user specified solve method)

todo

  - check for name clashes for new local variable declarations
  - probably linear matrix statements should go intoa new  e.g. EigenLinearSolverBlock?

  - missing codegen part:
      * insert matrix declarations above these matrix assignments (X, F, J)
      * insert eigen solve call after the matrix assignments (X = J^-1 F)
      * followed by assignment of state vars with the solve results X after this solve call

Change-Id: I1c6074a16489562be1afce1cb7e9ad1db6832079
pramodk pushed a commit that referenced this issue Mar 23, 2019
  - SympySolver visitor also visits LINEAR blocks now
  - For small systems, replaces eqs directly with solutions
  - For larger systems, replaces with matrix system to be solved (codegen required)
      * this change resolves #57 (numerical instability of sparse solver)
  - In both cases it inserts the equations in the right location in the statement block
      * this change partially resolves #55 (order of statements in DERIVATIVE block)
  - Add some unit tests

also
  - refactored solvers: KINETIC -> DERIVATIVE -> (NON_)LINEAR
      * first any KINETIC blocks are converted to DERIVATIVE blocks
      * then ODEs in DERIVATIVE blocks are converted to a system of (non)linear equations
      * these are then solved with the same solvers as LINEAR or NON_LINEAR blocks
      * reduces unnecessary duplication of functionality
      * this change resolves #46 (sympy solver ignoring user specified solve method)

todo

  - check for name clashes for new local variable declarations
  - probably linear matrix statements should go intoa new  e.g. EigenLinearSolverBlock?

  - missing codegen part:
      * insert matrix declarations above these matrix assignments (X, F, J)
      * insert eigen solve call after the matrix assignments (X = J^-1 F)
      * followed by assignment of state vars with the solve results X after this solve call

Change-Id: I1c6074a16489562be1afce1cb7e9ad1db6832079
pramodk pushed a commit that referenced this issue Mar 25, 2019
  - SympySolver visitor also visits LINEAR blocks now
  - For small systems, replaces eqs directly with solutions
  - For larger systems, replaces with matrix system to be solved (codegen required)
      * this change resolves #57 (numerical instability of sparse solver)
  - In both cases it inserts the equations in the right location in the statement block
      * this change partially resolves #55 (order of statements in DERIVATIVE block)
  - Add some unit tests

also
  - refactored solvers: KINETIC -> DERIVATIVE -> (NON_)LINEAR
      * first any KINETIC blocks are converted to DERIVATIVE blocks
      * then ODEs in DERIVATIVE blocks are converted to a system of (non)linear equations
      * these are then solved with the same solvers as LINEAR or NON_LINEAR blocks
      * reduces unnecessary duplication of functionality
      * this change resolves #46 (sympy solver ignoring user specified solve method)

todo

  - check for name clashes for new local variable declarations
  - probably linear matrix statements should go intoa new  e.g. EigenLinearSolverBlock?

  - missing codegen part:
      * insert matrix declarations above these matrix assignments (X, F, J)
      * insert eigen solve call after the matrix assignments (X = J^-1 F)
      * followed by assignment of state vars with the solve results X after this solve call

Change-Id: I1c6074a16489562be1afce1cb7e9ad1db6832079
pramodk pushed a commit that referenced this issue Mar 25, 2019
  - SympySolver visitor also visits LINEAR blocks now
  - For small systems, replaces eqs directly with solutions
  - For larger systems, replaces with matrix system to be solved (codegen required)
      * this change resolves #57 (numerical instability of sparse solver)
  - In both cases it inserts the equations in the right location in the statement block
      * this change partially resolves #55 (order of statements in DERIVATIVE block)
  - Add some unit tests

also
  - refactored solvers: KINETIC -> DERIVATIVE -> (NON_)LINEAR
      * first any KINETIC blocks are converted to DERIVATIVE blocks
      * then ODEs in DERIVATIVE blocks are converted to a system of (non)linear equations
      * these are then solved with the same solvers as LINEAR or NON_LINEAR blocks
      * reduces unnecessary duplication of functionality
      * this change resolves #46 (sympy solver ignoring user specified solve method)

todo

  - check for name clashes for new local variable declarations
  - probably linear matrix statements should go intoa new  e.g. EigenLinearSolverBlock?

  - missing codegen part:
      * insert matrix declarations above these matrix assignments (X, F, J)
      * insert eigen solve call after the matrix assignments (X = J^-1 F)
      * followed by assignment of state vars with the solve results X after this solve call

Change-Id: I1c6074a16489562be1afce1cb7e9ad1db6832079
pramodk added a commit that referenced this issue Mar 25, 2019
  - SympySolver visitor also visits LINEAR blocks now
  - for small systems, replaces eqs directly with solutions
  - for larger systems, replaces with matrix system to be solved (codegen required)
       this change resolves #57 (numerical instability of sparse solver)
  - in both cases it inserts the equations in the right location in the statement block
       this change partially resolves #55 (order of statements in DERIVATIVE block)
  - add unit tests
  - added code generation support for eigen linear solve block
  - added initialize & finalize block for newton solver
  - add number of state vars to eigen solve blocks : codegen needs to know how
     many state vars in each solve block and this might not be the number of prime
     vars (e.g. LINEAR block)
  - EIGEN blocks in codegen.yaml now contain n_state_vars integer

Also

  - refactored solvers: KINETIC -> DERIVATIVE -> (NON_)LINEAR
    - first any KINETIC blocks are converted to DERIVATIVE blocks
    - then ODEs in DERIVATIVE blocks are converted to a system of (non)linear equations
    - these are then solved with the same solvers as LINEAR or NON_LINEAR blocks
    - reduces unnecessary duplication of functionality
    - this change resolves #46 (sympy solver ignoring user specified solve method)

Todo
  - check for name clashes for new local variable declarations

Resolve #64
Resolves #57
Resolves #46

Co-Authored-By: pramodk <pramod.s.kumbhar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working codegen Code generation backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants