I am very very new to matlab, actually I only just got the program to run one code. A good friend of mine wrote a code for me however it doesn't seem to work, I have provided the link to the code and data files required, can anyone tell me what's wrong or fix it for me? Much thanks!
The error I am getting is:
Warning: No such number of days in the future exist for a 30/360 day-count basis. > In daysadd at 141 In CDS_PD at 35
https://www.dropbox.com/s/jtjk187rpu0fhv5/cds.zip
It appears that it is only a warning and is an inherent limitation of the "30/360 day-count basis" as used by the daycount function. As far as I can tell it just means that the calculated day is not unique in this basis. So it doesn't necessarily mean that the program is functioning incorrectly.
See:
http://www.mathworks.com.au/help/finance/daysadd.html
http://www.mathworks.com.au/help/finance/_f0-6010.html#bsuk32t-1
http://www.google.com.au/search?q=30%2F360+day-count+basis
Related
My DES model was working well till I've added a new function (just like many others added before) and the model gave me all these error messages:
I wonder what do these messages mean and what made all of them appear suddenly. I was running the model just before it without any errors. Is there a way I could get my model back? :)
Thank you.
Edit 1:
Here is the newly created function: Newly created function
Given that I've ignored it, and made all the callings of it as comments, then the errors were still appearing. I've closed this model version and opened a backup then created the same function and the whole scenario happened again with the same 94 errors.
Is there something I need to change in the function itself?
The function checks the number of agents in certain parts of the model to stop delay blocks accordingly. That's done by adding variables that increment on exiting of agents and get the difference between them.
Typically this is caused by a syntax error in the new function that you created. See if you ignore this and then compile if it gets fixed.
Most of the time the compiler is smart enough to show you the error, but often if you replace a { with [ or you leave out a { the compiler get very confused and gives you 100s of errors.
If yous still cant find the issue maybe paste the code of your new function in the question.
I am trying to implement a simple form of transporter routing choice algorithm but I am having some trouble using some of the functions as given by Anylogic help. My model basically just tries to check the number of transporters in the next following path and node and then evaluates accordingly to pick the route. It is not complete as of now but the picture below shows my current implementation:
While compiling and executing the program, I received 2 errors and hope some advice can be provided.
Error 1
Error 1 can be seen in the screen capture above. Why is my function call erroneous?
Error 2
I am not too sure why this is happening either. Any advice?
Appreciate all the help given!
I have a model that I can run in winbugs but I get an error in openbugs when loading and generating initial values even when using the same code and the same data.
When loading initial values in both winbugs and openbugs I get the message that the "chain contains uninitalized variables". Then I can successfully generate initial values in winbugs but in openbugs I get the error "error for node Ny[2] of type GraphBinoimial. Node second argument must be integer valued." My initial values for Ny are Ny=c(4,4,4,4,4,4,4,4). These seem like integers to me. Plus these same initial values are accepted in winbugs.
You may be asking yourself, if I can get it work in winbugs why do I care to get it to work in openbugs? I am most interested in running the whole process through R. I've been trying to do this with R2Winbugs or Brugs (openbugs) but I get errors on initialization with both of these and it even crashes R (I'd never seen the r-bomb before but now I can make it happen repeatedly). I think this is probably for the same reason that I can't run the data manually in openbugs.
Being able to run this through R would greatly reduce the frustration of interacting with win/openbugs especially when running a series of models with different data.
Thanks in advance for your insight.
lg
I am new to StackOverflow so please correct me if there is a better way to post a question which is a specific case of an existing question.
Alberto Barrera answered
How does one seed the random number generator in Swift?
with
let time = UInt32(NSDate().timeIntervalSinceReferenceDate)
srand(time)
print("Random number: \(rand()%10)")
which is perfect generally, but when I try it in The IBM Swift Sandbox it gives the same number sequence every run, at least in the space of a half hour.
import Foundation
import CoreFoundation
let time = UInt32(NSDate().timeIntervalSinceReferenceDate)
srand(time)
print("Random number: \(rand()%10)")
At the moment, every Run prints 5.
Has anyone found a way to do this in the IBM Sandbox? I have found that random() and srandom() produce a different number sequence but similarly are the same each Run. I haven't found arc4random() in Foundation, CoreFoundation, Darwin, or Glibc.
As an aside, I humbly suggest someone with reputation above 1500 creates a tag IBM-Swift-Sandbox.
This was an issue with the way we implemented server-side caching in the Sandbox; non-deterministic code would continually return the same answer even though it should not have. We've disabled it for now, and you should be getting different results with each run. We're currently working on better mechanisms to ensure the scalability of the Sandbox.
I'll see about that tag, as well!
srand is working as expected. If you change value each time in let time = UInt32(NSDate().timeIntervalSinceReferenceDate) instead of NSDate().timeIntervalSinceReferenceDate with any number, it will output random numbers.
Maybe this is a caching issue, it just doesn't see any changes in code and doesn't send it for recompilation :)
I don't know what is going on but today it is totally working. So I guess the question is answered:
srand(UInt32(NSDate().timeIntervalSinceReferenceDate))
works fine.
(I think something must have changed. It was behaving the same way (generating the same number with repeated attempts) on two different computers for about 10 days... Bizarre.)
I have a question about inner Matlab error management. Right now I have quite a large program with a lot of variables and functions that cumulated over my code writting and I'm 100 percent sure that I did not catch all the bugs and mistakes in the program and I don't want it to crash completely when is used by layman user. So, is there a way to display errordlg message and for example restart the program when there will be any given error directly by Matlab (for example when I forgot to declare a global variable etc.)?
Thanks for answers, Peter
Crashes are good, because they force users to report bugs.
If you don't want to go that route, Matlab provides try-catch: wrap your code in a try-catch block. If there is an error, you'll find yourself in the catch block where you can have Matlab send you an email with the error message, and restart the program if necessary.
You can use try/catch statements to respond to errors in your program. There's more information here.