[Scilab-users] ?==?utf-8?q? Scilab control after an impossible calculation

Antoine Monmayrant amonmayr at laas.fr
Thu Oct 6 12:39:42 CEST 2016


Hi Paul,

Here are a couple of things you can do:

- as already mentioned, try/catch structures can be used to handle problems instead of crashing.
- can't you bullet-proof your code? I mean check x!=0 if you have 1/x somewhere in your code.
-  just change your parametrization to use y=1/x as a parameter instead of x. Basically, you just change all the parameters so that your scilab calculation is safe and you make a small translator (y->x=1/y, ...) to easily navigate from safe parameters to parameters that make sense for the user. We use it a lot in our curve fitting procedures to avoid similar 1/(x=0), acos(x>1), log(x<=0) ... problems.
- can't you use constraints in your optimization routine? I think optim and leastsqr can use optional arguments to coerce each parameter in a given range.

Hope it helps,

Antoine

 
Le Jeudi, Octobre 06, 2016 10:51 CEST, paul.carrico at free.fr a écrit: 
 
> 
> Hi All 
> 
> I’m using Scilab as the interface between my optimizer and my finite element solver(s) and sometimes Scilab stops because of unexpected and impossible calculus (1/x with x = 0 as an example ); obviously Scilab stops (and so the optimization). 
> 
> I’m wondering if it’s possible: 
> - To ask back Scilab a message such as “hey I crashed because you’re a fool and you’ve not anticipated an impossible calculation !!!” 
> - To get back Scilab control in order to avoid optimization process crash ? I’ve been thinking in affecting a cost function value at %inf for example (not elegant I recognize) 
> 
> I don’t know if I’m understandable enough … 
> 
> Paul




More information about the users mailing list