就我而言, 如果位的值为“ 1”,则我的约束将对“ 1”具有更高的权重;如果位为“ 0”,则我的约束将对“ 0”具有更高的权重。如何约束它?
此段代码出现语法错误
library(kableExtra)
x1 <- knitr::kable(head(mtcars), "html")
Test2 <- c(" ", مواطنين = "5", `غير مواطنين` = "6")
Test3 <- c(`\textarabic{}` = " ", `\textarabic{مواطنين}` = "5",
`\textarabic{غير مواطنين}` = "6")
add_header_above(x1, Test2, escape = FALSE)
add_header_above(x1, Test3, escape = FALSE)
请帮助我。谢谢:)
答案 0 :(得分:1)
您可以将if-else置于约束中
rand bit value;
bit x;
constraint c {
if(x)
value dist {1 := 3, 0 := 1};
else
value dist {1 := 1, 0 := 3};
}
您的权重也可以是变量
int weight0, weight1;
constraint c {
value dist {1 := weight1, 0 := weight0};
// set before calling randomize
if (x) begin
weight1 = 3; weight0 =1;
end else begin
weight1 = 1; weight0 =3;
end
或表达式
constraint c {
value dist {1 := x?3:1, 0 := x?1:3};