Skip to content

能否在一行中实现多个selector? #25

Answered by qizhou
readygo67 asked this question in Q&A
Discussion options

You must be logged in to vote

默认的simple selector不能跟其他的selector混用(会影响优化)。可以把simple selector换成complex selector如下:

        // Create a fixed column to load constants,分配一个cosntant 列
        // let constant = meta.fixed_column();
        let selectors = [meta.complex_selector(), meta.complex_selector(), meta.complex_selector()];

程序就可以跑通了。

但是,在这个例子里面,我们建议不要使用连加作为约束,因为会出现多个selector为1,并且每个selector相乘的多项式数值不为0,导致每个selector的多项式的无法分别单独约束。

vec![s_add * (lhs.clone() + rhs.clone() - sum) + s_sub * (lhs.clone() - rhs.clone() - difference) + s_mul * (lhs * rhs - product)] 

比如,这里面可以让s_add = s_sub = 1,同时sum = lhs * 2, difference = 0,一样是可以通过约束检查,但是并没有实现lhs + rhs = sumlhs - rhs = diff的约束。

最好的方式是把他们分开如下:

vec![s_add * (lhs.clone() + rh…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by readygo67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants