Changeset 733

Show
Ignore:
Timestamp:
08/27/10 14:39:33 (1 year ago)
Author:
dmitrey
Message:

some changes wrt FD getOrder

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • PythonPackages/FuncDesigner/FuncDesigner/__init__.py

    r639 r733  
    11from ooVar import oovar, oovars 
    2 from ooFun import NonLinearConstraint, _getAllAttachedConstraints, broadcast, ooFun as oofun 
     2from ooFun import _getAllAttachedConstraints, broadcast, ooFun as oofun 
    33from ooSystem import ooSystem as oosystem 
    44from translator import FuncDesignerTranslator as ootranslator 
  • PythonPackages/FuncDesigner/FuncDesigner/ooFun.py

    r732 r733  
    451451        if self.is_oovar and not isinstance(other, oofun): 
    452452            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! 
    457455        return r 
    458456 
     
    466464        if self.is_oovar and not isinstance(other, oofun): 
    467465            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! 
    472468        return r             
    473469 
     
    481477        if self.is_oovar and not isinstance(other, oofun): 
    482478            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! 
    487480        return r   
    488481 
     
    11011094     
    11021095 
    1103 class NonLinearConstraint(SmoothFDConstraint): 
     1096class Constraint(SmoothFDConstraint): 
    11041097    def __init__(self, *args, **kwargs): 
    11051098        SmoothFDConstraint.__init__(self, *args, **kwargs) 
     
    11101103        SmoothFDConstraint.__init__(self, *args, **kwargs) 
    11111104         
    1112 class LinearConstraint(SmoothFDConstraint): 
    1113     def __init__(self, *args, **kwargs): 
    1114         SmoothFDConstraint.__init__(self, *args, **kwargs) 
    1115  
    11161105class Derivative(dict): 
    11171106    def __init__(self): 
  • PythonPackages/FuncDesigner/FuncDesigner/ooSystem.py

    r731 r733  
    110110        else: 
    111111            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]) 
    114116        if isLinear: 
    115117            p = openopt.LP(objective, *args, **kwargs)