Solved by ayalaa2 in post #9 
              
              
                I made a simple model that has one layer (linear, so I adjusted your if condition) and the only objective function was yours. I did see that it was unchanging at 0.005 after an optimization step until I bumped up lambd, then I saw that it was changing. 
Even with bumping your lambd value up you don’…