Changeset 733
- Timestamp:
- 08/27/10 14:39:33 (1 year ago)
- Files:
-
- PythonPackages/FuncDesigner/FuncDesigner/__init__.py (modified) (1 diff)
- PythonPackages/FuncDesigner/FuncDesigner/ooFun.py (modified) (5 diffs)
- PythonPackages/FuncDesigner/FuncDesigner/ooSystem.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PythonPackages/FuncDesigner/FuncDesigner/__init__.py
r639 r733 1 1 from ooVar import oovar, oovars 2 from ooFun import NonLinearConstraint,_getAllAttachedConstraints, broadcast, ooFun as oofun2 from ooFun import _getAllAttachedConstraints, broadcast, ooFun as oofun 3 3 from ooSystem import ooSystem as oosystem 4 4 from translator import FuncDesignerTranslator as ootranslator PythonPackages/FuncDesigner/FuncDesigner/ooFun.py
r732 r733 451 451 if self.is_oovar and not isinstance(other, oofun): 452 452 r = BoxBoundConstraint(self, lb = other) 453 elif self.is_linear and (not isinstance(other, oofun) or other.is_linear): 454 r = LinearConstraint(self-other, lb = 0.0) 455 else: 456 r = NonLinearConstraint(self - other, lb=0.0) # do not perform check for other == 0, copy should be returned, not self! 453 else: 454 r = Constraint(self - other, lb=0.0) # do not perform check for other == 0, copy should be returned, not self! 457 455 return r 458 456 … … 466 464 if self.is_oovar and not isinstance(other, oofun): 467 465 r = BoxBoundConstraint(self, ub = other) 468 elif self.is_linear and (not isinstance(other, oofun) or other.is_linear): 469 r = LinearConstraint(self-other, ub = 0.0) 470 else: 471 r = NonLinearConstraint(self - other, ub = 0.0) # do not perform check for other == 0, copy should be returned, not self! 466 else: 467 r = Constraint(self - other, ub = 0.0) # do not perform check for other == 0, copy should be returned, not self! 472 468 return r 473 469 … … 481 477 if self.is_oovar and not isinstance(other, oofun): 482 478 raise FuncDesignerException('Constraints like this: "myOOVar = <some value>" are not implemented yet and are not recommended; for openopt use optVars / fixedVars instead') 483 if self.is_linear and (not isinstance(other, oofun) or other.is_linear): 484 r = LinearConstraint(self-other, ub = 0.0, lb = 0.0) 485 else: 486 r = NonLinearConstraint(self - other, ub = 0.0, lb = 0.0) # do not perform check for other == 0, copy should be returned, not self! 479 r = Constraint(self - other, ub = 0.0, lb = 0.0) # do not perform check for other == 0, copy should be returned, not self! 487 480 return r 488 481 … … 1101 1094 1102 1095 1103 class NonLinearConstraint(SmoothFDConstraint):1096 class Constraint(SmoothFDConstraint): 1104 1097 def __init__(self, *args, **kwargs): 1105 1098 SmoothFDConstraint.__init__(self, *args, **kwargs) … … 1110 1103 SmoothFDConstraint.__init__(self, *args, **kwargs) 1111 1104 1112 class LinearConstraint(SmoothFDConstraint):1113 def __init__(self, *args, **kwargs):1114 SmoothFDConstraint.__init__(self, *args, **kwargs)1115 1116 1105 class Derivative(dict): 1117 1106 def __init__(self): PythonPackages/FuncDesigner/FuncDesigner/ooSystem.py
r731 r733 110 110 else: 111 111 kwargs['constraints'] = constraints 112 113 isLinear = objective.getOrder(self.optVars, self.fixedVars) < 2 and all([(c.oofun.getOrder(self.optVars, self.fixedVars) < 2) for c in constraints]) 112 113 optVars = kwargs.get('optVars', None) 114 fixedVars = kwargs.get('fixedVars', None) 115 isLinear = objective.getOrder(optVars, fixedVars) < 2 and all([(c.oofun.getOrder(optVars, fixedVars) < 2) for c in constraints]) 114 116 if isLinear: 115 117 p = openopt.LP(objective, *args, **kwargs)
