Ignore:
Timestamp:
09/28/15 20:45:46 (8 months ago)
Author:
mmckerns
Message:

add simplify to simplify equations for a single variable on the LHS;
use simplify in many examples where symbolic equations are given;
add comparator function, to determine the comparator ('<=', '=', etc);
add test_simplify to test_symbolic

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mystic/examples2/optqp.py

    r816 r831  
    3030from mystic.symbolic import generate_conditions, generate_penalty 
    3131pf = generate_penalty(generate_conditions(equations), k=1e4) 
     32from mystic.symbolic import generate_constraint, generate_solvers, solve 
     33cf = generate_constraint(generate_solvers(solve(equations))) 
    3234 
    3335# inverted objective, used in solving for the maximum 
     
    4042  from mystic.math import almostEqual 
    4143 
    42   result = diffev2(_objective, x0=bounds, bounds=bounds, penalty=pf, npop=40, ftol=1e-8, gtol=100, disp=False, full_output=True) 
     44  result = diffev2(_objective, x0=bounds, bounds=bounds, constraint=cf, penalty=pf, npop=40, ftol=1e-8, gtol=100, disp=False, full_output=True) 
    4345  assert almostEqual(result[0], xs, rel=2e-2) 
    4446  assert almostEqual(result[1], ys, rel=2e-2) 
    4547 
    46   result = fmin_powell(_objective, x0=[-1.0,1.0], bounds=bounds, penalty=pf, disp=False, full_output=True) 
     48  result = fmin_powell(_objective, x0=[-1.0,1.0], bounds=bounds, constraint=cf, penalty=pf, disp=False, full_output=True) 
    4749  assert almostEqual(result[0], xs, rel=2e-2) 
    4850  assert almostEqual(result[1], ys, rel=2e-2) 
    4951 
    5052 
    51 # EOD 
     53# EOF 
Note: See TracChangeset for help on using the changeset viewer.