Skip to content

Conversation

@odow
Copy link
Member

@odow odow commented Mar 6, 2025

No description provided.

@odow odow force-pushed the od/symbolic-divide branch from f89128d to f12640a Compare March 6, 2025 03:16
@odow odow changed the title [Nonlinear.SymbolicAD] add two more simplification cases [Nonlinear.SymbolicAD] simplify quadratic functions if possible Mar 6, 2025
@odow
Copy link
Member Author

odow commented Mar 6, 2025

Now this would help a bunch of #2553

julia> op(head, args...) = MOI.ScalarNonlinearFunction(head, Any[args...])
op (generic function with 1 method)

julia> f = op(:/, 
           op(:+, 
               op(:-, 
                   op(:+, 
                       op(:^, MOI.VariableIndex(9), (2)),
                       op(:^, MOI.VariableIndex(6), (2)),
                       op(:^, MOI.VariableIndex(7), (2)),
                   ), 
                   0.0,
               ), 
               op(:-, 
                   op(:+, 
                       op(:^, MOI.VariableIndex(9), (2)),
                       op(:^, MOI.VariableIndex(6), (2)),
                       op(:^, MOI.VariableIndex(7), (2)),
                   ),
                   0.0,
               ),
               op(:+, 
                   op(:-, 
                       op(:+, 
                           MOI.VariableIndex(6),
                       ),
                   ),
               ),
               op(:+, 
                   op(:-, 
                       op(:+, 
                           MOI.VariableIndex(7),
                       ),
                   ),
               ), 
               op(:+, 
                   op(:+, 
                       MOI.VariableIndex(6),
                   ),
               ), 
               op(:+, 
                   op(:+, 
                       MOI.VariableIndex(7),
                   ),
               ),
           ),
           2.0,
       )
/(+(-(+(^(MOI.VariableIndex(9), (2)), ^(MOI.VariableIndex(6), (2)), ^(MOI.VariableIndex(7), (2))), 0.0), -(+(^(MOI.VariableIndex(9), (2)), ^(MOI.VariableIndex(6), (2)), ^(MOI.VariableIndex(7), (2))), 0.0), +(-(+(MOI.VariableIndex(6)))), +(-(+(MOI.VariableIndex(7)))), +(+(MOI.VariableIndex(6))), +(+(MOI.VariableIndex(7)))), 2.0)

julia> MOI.Nonlinear.SymbolicAD.simplify(f)
0.0 + 1.0 MOI.VariableIndex(6+ 1.0 MOI.VariableIndex(7+ 1.0 MOI.VariableIndex(9

@odow odow merged commit 9ea9a80 into master Mar 6, 2025
31 checks passed
@odow odow deleted the od/symbolic-divide branch March 6, 2025 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants