/[ascend]/trunk/pygtk/interface/solverparameter.cpp
ViewVC logotype

Diff of /trunk/pygtk/interface/solverparameter.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 224 by johnpye, Fri Jan 27 03:05:38 2006 UTC revision 225 by johnpye, Fri Jan 27 14:55:43 2006 UTC
# Line 82  SolverParameter::getIntUpperBound() cons Line 82  SolverParameter::getIntUpperBound() cons
82      return p->info.i.high;      return p->info.i.high;
83  }  }
84    
85    void
86    SolverParameter::setIntValue(const int &val){
87        if(!isInt()){
88            throw runtime_error("Not an integer parameter");
89        }
90        if(isBounded() && (val > getIntUpperBound() || val < getIntLowerBound())){
91            throw runtime_error("Out of bounds");
92        }
93        p->info.i.value = val;
94    }
95    
96  // Boolean parameters  // Boolean parameters
97    
98  const bool  const bool
# Line 92  SolverParameter::getBoolValue() const{ Line 103  SolverParameter::getBoolValue() const{
103      return p->info.b.value !=0;      return p->info.b.value !=0;
104  }  }
105    
106    void
107    SolverParameter::setBoolValue(const bool &val){
108        if(!isBool()){
109            throw runtime_error("Not a boolean parameter");
110        }
111        p->info.b.value = val;
112    }
113    
114  // Real parameters  // Real parameters
115    
116  const double &  const double &
# Line 118  SolverParameter::getRealUpperBound() con Line 137  SolverParameter::getRealUpperBound() con
137      return p->info.r.high;      return p->info.r.high;
138  }  }
139    
140    void
141    SolverParameter::setRealValue(const double &val){
142        if(!isReal()){
143            throw runtime_error("Not a real parameter");
144        }
145        if(isBounded() && (val > getRealUpperBound() || val < getRealLowerBound())){
146            throw runtime_error("Out of bounds");
147        }
148        p->info.r.value = val;
149    }
150    
151  // String parameters  // String parameters
152    
153  const string  const string
# Line 140  SolverParameter::getStrOptions() const{ Line 170  SolverParameter::getStrOptions() const{
170      return v;      return v;
171  };  };
172    
173    void
174    SolverParameter::setStrOption(const int &opt){
175        if(!isStr()){
176            throw runtime_error("Not a string parameter");
177        }
178        if(opt < 0 || opt > p->info.c.high){
179            throw runtime_error("Invalid option index");
180        }
181        slv_set_char_parameter(&(p->info.c.value),p->info.c.argv[opt]);
182    }
183    
184    void
185    SolverParameter::setStrValue(const std::string &str){
186        if(!isStr()){
187            throw runtime_error("Not a string parameter");
188        }
189        slv_set_char_parameter( &(p->info.c.value),str.c_str() );
190    }
191    
192  // To String  // To String
193    
194  const string  const string
# Line 147  SolverParameter::toString() const{ Line 196  SolverParameter::toString() const{
196      return "STRING";      return "STRING";
197  }  }
198    
199    // Bounded?
200    
201    const bool
202    SolverParameter::isBounded() const{
203        if(isInt() && getIntLowerBound() < getIntUpperBound()){
204            return true;
205        }else if(isReal() && getRealLowerBound() < getRealUpperBound()){
206            return true;
207        }
208        return false;
209    }
210    
211    
212    

Legend:
Removed from v.224  
changed lines
  Added in v.225

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22