设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 7891|回复: 4

[求助] 请问如何使用代码实现随机数种子的设置?

[复制链接]
发表于 2008-12-11 23:28:08 | 显示全部楼层 |阅读模式
5仿真币
我的license不支持experiment manager对象。。。. `) F. L7 \$ E# ~, Q0 H5 X/ ]
  q! X  Y9 P5 ?0 H
所以请问使用代码可以实现吗?就比如像c++或者java里面,取当前时间作为种子,填入stream中?
$ y" v8 _" P% Z7 U+ x! w7 o
( ^. e' F+ f) h6 |如何写?用到哪些方法?和属性?% {' I8 L+ \+ \
* @3 T- A8 ~0 \6 x) J; L* |# E
谢谢了

最佳答案

查看完整内容

用到这个.Stream := ; 如果你要设置singleProc的处理时间(proctime)的随机种子为当前的仿真时间,可以这样: singleProc.proctime.Stream :=time_to_num( root.eventController.simTim);
发表于 2008-12-11 23:28:09 | 显示全部楼层
用到这个<attribute_path>.Stream := <integer>;) e* y2 S( c6 F$ h8 n+ @' s
如果你要设置singleProc的处理时间(proctime)的随机种子为当前的仿真时间,可以这样:
( O! h6 b$ m9 N& h6 osingleProc.proctime.Stream :=time_to_num( root.eventController.simTim);
 楼主| 发表于 2008-12-12 14:02:55 | 显示全部楼层
对了,系统时间如何获得啊?
 楼主| 发表于 2008-12-14 15:56:21 | 显示全部楼层
time_to_num()这个函数不存在,只存在这些函数:
7 e  q/ z8 `" B5 q. y/ J9 TConversion Method  Data Type of the Return Value % @$ o8 m* \" l  }
bool_to_num(<boolean>) real + b) `9 V  j* X- `' r) O9 {
num_to_bool(<integer>) boolean ! o" R" H0 g4 _# R
str_to_bool(<string>) boolean
% a( \+ l1 F& y; }+ Sstr_to_date(<string>) time : g. X5 ]+ W3 s8 @! v
str_to_datetime(<string>) datetime
, ~% ~9 i. P& N% C  pstr_to_length(<string>) length
7 ]2 n/ `5 l% i9 y1 ostr_to_num(<string>) real 1 [  d) _: _5 _5 F! Z3 V5 R7 T
str_to_obj(<string>) object - A, _8 n# d  w9 c
str_to_speed(<string>) speed 1 H, R+ g1 Q: T2 G7 @4 j4 Q) c
str_to_time(<string>) time # D* r) |# o+ O" m
str_to_weight(<string>) weight
* u/ n9 |& e% l2 l% z' }+ Zto_str(<any>, ...) string
& |  p0 |) \6 t" j我的是7.0版,不知道8.1有没有。
 楼主| 发表于 2008-12-14 16:17:52 | 显示全部楼层
我的解决办法:9 G: \- B5 v, T1 k6 f+ T
singleProc.proctime.Stream :=str_to_num(to_str( timeOfDay(sysDate)*100000));
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2026-7-26 21:29 , Processed in 0.022965 second(s), 13 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表