Wu-Lab / BlockSim

R package for Blockchain Simulation and Research Tools
0 stars 0 forks source link

请问有没有演示示例? #1

Open Tough-Stone opened 4 years ago

Tough-Stone commented 4 years ago

请问有没有演示示例,如何使用这个项目

wulingyun commented 4 years ago

没有。这个项目主要是用于模拟区块链的DAG结构,进而分析区块链的分叉、性能等,并不能用于具体的区块链系统。

Tough-Stone commented 4 years ago

明白,就是想问下怎么进行模拟

wulingyun commented 4 years ago

模拟用函数 simulate_blockchain,具体参数见帮助文档

Tough-Stone commented 4 years ago

这个BlockSim包找不到,是什么原因呢

wulingyun commented 4 years ago

这个包没有提交到CRAN,需要自己下载用源文件方式安装,或者用devtools包提供的工具:

library(devtools) install_github("wulingyun/BlockSim")

Tough-Stone commented 4 years ago

十分感谢。我执行simulate_blockchain以后,只是打印一些数据,统计图又是怎样生成的呢?

--------------原始邮件-------------- 发件人:"Ling-Yun Wu "<notifications@github.com>; 发送时间:2020年2月5日(星期三) 下午3:40 收件人:"wulingyun/BlockSim" <BlockSim@noreply.github.com>; 抄送:"lhx0525 "<1821310082@bwu.edu.cn>;"Author "<author@noreply.github.com>; 主题:Re: [wulingyun/BlockSim] 请问有没有演示示例? (#1)

这个包没有提交到CRAN,需要自己下载用源文件方式安装,或者用devtools包提供的工具:

library(devtools) install_github("wulingyun/BlockSim")

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wulingyun commented 4 years ago

R有很强大的统计和画图功能,需要根据具体目的去进行统计和画图

Tough-Stone commented 4 years ago

可以举个例子吗,根据计算出来的结果生成一张图片

--------------原始邮件-------------- 发件人:"Ling-Yun Wu "<notifications@github.com>; 发送时间:2020年2月5日(星期三) 下午3:52 收件人:"wulingyun/BlockSim" <BlockSim@noreply.github.com>; 抄送:"lhx0525 "<1821310082@bwu.edu.cn>;"Author "<author@noreply.github.com>; 主题:Re: [wulingyun/BlockSim] 请问有没有演示示例? (#1)

R有很强大的统计和画图功能,需要根据具体目的去进行统计和画图

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

wulingyun commented 4 years ago

library(BlockSim) library(reshape2) library(ggplot2)

lambda <- seq(0, 0.1, length.out = 100)

y1 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 1), block_size = 1) y2 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 2), block_size = 2) y3 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 4), block_size = 4) y01 <- tx_per_second(lambda, block_size = 1) y02 <- tx_per_second(lambda, block_size = 2) y03 <- tx_per_second(lambda, block_size = 4)

TPS <- data.frame(lambda = lambda, y1 = y1, y2 = y2, y3 = y3) dd = melt(TPS, id=c("lambda"))

TPS0 <- data.frame(lambda = lambda, y1 = y01, y2 = y02, y3 = y03) dd0 = melt(TPS0, id=c("lambda")) dd0 <- dd0[dd0$value < 300, ]

p <- ggplot(dd) + geom_line(aes(x = lambda, y = value, colour = variable, linetype = "solid")) + geom_line(data = dd0, aes(x = lambda, y = value, colour = variable, linetype = "dashed")) + scale_colour_manual(name = "Block size", values = c("blue", "green", "red"), labels = c("1M", "2M", "4M")) + scale_linetype_manual(name = "Models", values = c("dashed", "solid"), labels = c("Theoretical maximum", "Gamma distribution")) + xlab("Block creation rate (block/s)") + ylab("Transaction Throughput (tx/s)") + theme(legend.position = c(0.01,0.99), legend.justification = c(0,1)) ggsave("TPS_lambda.png", p, height = 5, dpi = 1200)

Tough-Stone commented 4 years ago

十分感谢!

--------------原始邮件-------------- 发件人:"Ling-Yun Wu "<notifications@github.com>; 发送时间:2020年2月5日(星期三) 下午3:59 收件人:"wulingyun/BlockSim" <BlockSim@noreply.github.com>; 抄送:"lhx0525 "<1821310082@bwu.edu.cn>;"Author "<author@noreply.github.com>; 主题:Re: [wulingyun/BlockSim] 请问有没有演示示例? (#1)

library(BlockSim) library(reshape2) library(ggplot2)

lambda <- seq(0, 0.1, length.out = 100)

y1 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 1), block_size = 1) y2 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 2), block_size = 2) y3 <- tx_per_second(sapply(lambda, estimate_growth_rate, block_size = 4), block_size = 4) y01 <- tx_per_second(lambda, block_size = 1) y02 <- tx_per_second(lambda, block_size = 2) y03 <- tx_per_second(lambda, block_size = 4)

TPS <- data.frame(lambda = lambda, y1 = y1, y2 = y2, y3 = y3) dd = melt(TPS, id=c("lambda"))

TPS0 <- data.frame(lambda = lambda, y1 = y01, y2 = y02, y3 = y03) dd0 = melt(TPS0, id=c("lambda")) dd0 <- dd0[dd0$value < 300, ]

p <- ggplot(dd) + geom_line(aes(x = lambda, y = value, colour = variable, linetype = "solid")) + geom_line(data = dd0, aes(x = lambda, y = value, colour = variable, linetype = "dashed")) + scale_colour_manual(name = "Block size", values = c("blue", "green", "red"), labels = c("1M", "2M", "4M")) + scale_linetype_manual(name = "Models", values = c("dashed", "solid"), labels = c("Theoretical maximum", "Gamma distribution")) + xlab("Block creation rate (block/s)") + ylab("Transaction Throughput (tx/s)") + theme(legend.position = c(0.01,0.99), legend.justification = c(0,1)) ggsave("TPS_lambda.png", p, height = 5, dpi = 1200)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.