为了克服这个问题,自己写了个setdest。贴上来大家一起讨论。 # ====================================================================== # default value # ====================================================================== set opt(nn) 50 ;# number of normal nodes set opt(fn) 0 ;# number of fast nodes set opt(ns1) 1.0 ;# min speed of normal nodes set opt(ns2) 3.0 ;# max speed of normal nodes set opt(fs1) 20.0 ;# min speed of fast nodes set opt(fs2) 30.0 ;# max speed of fast nodes set opt(t) 300.0 ;# simulation time set opt(x) 1000.0 ;# x dimension of space set opt(y) 1000.0 ;# y dimension of space set opt(seed) 1.0 ;# seed for random
proc getopt {argc argv} { ;# get cmd line opt global opt for {set i 0} {$i < $argc} {incr i} { set arg [lindex $argv $i] if {[string range $arg 0 0] != "-"} continue
set name [string range $arg 1 end] set opt($name) [lindex $argv [expr $i+1]] } }
proc distance {x1 y1 x2 y2} { global d set x1 [expr $x1 - $x2 ] set x1 [expr pow($x1, 2) ] set y1 [expr $y1 - $y2 ] set y1 [expr pow($y1, 2) ] set x1 [expr $x1 + $x2 ] set x1 [expr pow($x1, 0.5) ] set d $x1 }
ns自带setdest函数只能针对所有节点设置移动速度。如果我想让其中的10个节点移动速度较快,而另外40个节点较慢,自带的setdest就无能为力了。为了克服这个问题,自己写了个setdest。贴上来大家一起讨论。# ======================================================================# default va