- Timestamp:
- 12/18/12 19:39:55 (3 years ago)
- Location:
- branches/decorate
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/decorate/symbolic.py
r613 r614 215 215 Returns a tuple of inequality constraints and a tuple of equality constraints. 216 216 217 Inputs: 218 constraints -- a string of symbolic constraints, with one constraint 219 equation per line. Constraints can be equality and/or inequality 220 constraints. Standard python syntax should be followed (with the 221 math and numpy modules already imported). 222 217 223 For example: 218 224 >>> constraints = ''' … … 221 227 >>> penalty_parser(constraints, nvars=3) 222 228 (('-(x[0] - (0.))',), ('x[2] - (x[0]/2.)',)) 229 230 Additional Inputs: 231 nvars -- number of variables. Includes variables not explicitly 232 given by the constraint equations (e.g. 'x2' in the example above). 233 variables -- desired variable name. Default is 'x'. A list of variable 234 name strings is also accepted for when desired variable names 235 don't have the same base, and can include variables that are not 236 found in the constraints equation string. 223 237 """ 224 238 #from mystic.tools import src 225 239 #ndim = len(get_variables(src(func), variables)) 226 240 if list_or_tuple_or_ndarray(variables): 241 if nvars: variables = variables[:nvars] 227 242 constraints = replace_variables(constraints, variables) 228 243 varname = '$' … … 287 302 The left-hand side of each constraint must be simplified to support assignment. 288 303 304 Inputs: 305 constraints -- a string of symbolic constraints, with one constraint 306 equation per line. Constraints can be equality and/or inequality 307 constraints. Standard python syntax should be followed (with the 308 math and numpy modules already imported). 309 289 310 For example: 290 311 >>> constraints = ''' … … 293 314 >>> constraints_parser(constraints, nvars=3) 294 315 ('x[2] = x[0]/2.', 'x[0] = max(0., x[0])') 316 317 Additional Inputs: 318 nvars -- number of variables. Includes variables not explicitly 319 given by the constraint equations (e.g. 'x2' in the example above). 320 variables -- desired variable name. Default is 'x'. A list of variable 321 name strings is also accepted for when desired variable names 322 don't have the same base, and can include variables that are not 323 found in the constraints equation string. 295 324 """ 296 325 #from mystic.tools import src 297 326 #ndim = len(get_variables(src(func), variables)) 298 327 if list_or_tuple_or_ndarray(variables): 328 if nvars: variables = variables[:nvars] 299 329 constraints = replace_variables(constraints, variables) 300 330 varname = '$'
Note: See TracChangeset
for help on using the changeset viewer.