Comments (3)
When the value of testCoeff
is set to zero, the sparsity pattern is also being changed.
When testCoeff != 0
, then the jacobian spartity pattern will include an entry for variable 1 when ii = 0
and jj = 0
from the section:
testCoeff * advec((ii * dim1 + jj) * dim3 + 1) * advec((ii * dim1 + jj) * dim3 + 1)
// which is
testCoeff * advec((0 * dim1 + jj) * dim3 + 1) * advec((0 * dim1 + 0) * dim3 + 1)
// which is
testCoeff * advec(1) * advec(1)
The call to cgen.setCustomSparseJacobianElements(mappingRows, mappingCols)
assumes the elements to be a subset of the full sparsity pattern.
The failure is inside ADFun<Base>::SparseJacobianReverse()
which checks whether the provided elements are part of the sparsity pattern.
However, the sparsity pattern does not include the variable 1 when testCoeff = 0
.
I've added some additional documentation to reflect this.
from cppadcodegen.
Ok, but by speaking about a failure do you mean that this is expected from the developer point of view or may this be considered as a bug?
From the point of view of a user, this behaviour is rather unexpected, since often you cannot foresee whether "numeric" coefficients like testCoeff will become zero or not, e.g., when you implement an error function for an optimization algorithm and respective coefficients are linear combinations of other "numeric" coefficients.
from cppadcodegen.
At the moment it is expected for the developer to provide a correct sparsity pattern (would you really want to receive constant zeros in a sparse Jacobian/Hessian?).
CppadCodeGen does not perform any additional checks regarding the sparsity provided by the user and just forwards it to CppAD which, in turn, expects the developer to provide the correct sparsity.
The common use case to define a custom sparsity is to remove some elements which are not needed.
For this, it possible to compute the sparsity using CppAD::ADFun<CGD>
, remove the non-desired elements and then provide it to CppADCodeGen.
One would use the same strategy if we were just using CppAD.
CppAD now has explicit support for parameters, which will soon also be supported by CppADCodeGen (see feature/parameters ).
This will reduce the likelihood of setCustomSparseJacobianElements
being needed.
from cppadcodegen.
Related Issues (20)
- CppADCodeGen support for Eigen `.transpose()` operation HOT 6
- Found CppAD version '' but at least version '20200000.1' is required HOT 5
- Loops reusing intermediate results HOT 1
- Using LLVM to improve CppAD HOT 4
- Question about wrong type argument error
- Examples on using CppADCodeGen with Eigen HOT 5
- Use CppADCodeGen with variable number of independent variable arrays HOT 2
- GreaterThanZero cannot be called for non-parameters for eigen determinant HOT 2
- Code generation with if/else statements HOT 18
- Large computational graphs fail at link time HOT 4
- cppad_ipopt dependency HOT 3
- Calling CppAD::ipopt::solve from CppADCodeGen HOT 8
- How to get the value of a CppADCodeGen scalar type HOT 1
- Generating Jacobians as Tensors HOT 12
- icpc build fails for dynamic_linux.cpp example HOT 1
- make build_tests fails HOT 1
- Supporting runtime compilation and dynamic linking in MacOSX M1,2 chips HOT 2
- model->Domain() returns size for previous model
- Running the test program Jacobian module listwith cppAD library gives a lot of errors HOT 6
- error when complie function library
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cppadcodegen.