Comments (5)
Like the following feature:
'
@vsc.constraint
def basic_c(self):
with vsc.foreach(self.GroupList, idx=True, it=False) as idx:
self.GroupList[idx]<= self.mThreadNum
with vsc.foreach(self.GroupList, idx=True, it=False) as idx:
self.GroupList[idx]<= self.mThreadNum
with vsc.foreach(self.GroupList, idx=True, it=False) as idx:
with vsc.if_then(self.GroupList[idx] > 1):
self.GroupListScore[idx] == 1
with vsc.else_then():
self.GroupListScore[idx] == 0
self.GroupListScore.sum < self.getSum(self.GroupListScore)
self.GroupList.sum == self.mThreadNum
def getSum(self, aList):
return sum(aList)
'
from pyvsc.
Can you provide a full example that includes the definition of data fields?
Currently, PyVSC invokes functions when the constraint is built. So, getSum would be invoked once to obtain the size of the GroupListScore. Obviously, this behavior might not be what is desired.
from pyvsc.
For example, The following code doesn't run well for line 94:
Line 94 doesn't have caculation functions.
My question is how to meet similar requirement?
from pyvsc.
Hi @hanfeng0114,
Thank you for the full example. I created a small testcase based on the example. The error I receive from running this testcase is shown below:
File "/project/fun/pyvsc/pyvsc-20230821/src/vsc/rand_obj.py", line 208, in build_field_model
fo.c(self)
File "/project/fun/pyvsc/pyvsc-20230821/ve/unit/test_scalar_array.py", line 348, in basic_c
self.GroupList.sum == self.mThreadNum * self.mSharePercent/100
File "/project/fun/pyvsc/pyvsc-20230821/src/vsc/types.py", line 84, in __eq__
return self.bin_expr(BinExprType.Eq, rhs)
File "/project/fun/pyvsc/pyvsc-20230821/src/vsc/types.py", line 72, in bin_expr
to_expr(rhs)
File "/project/fun/pyvsc/pyvsc-20230821/src/vsc/types.py", line 338, in to_expr
raise Exception("Element \"" + str(t) + "\" isn't recognized, and doesn't provide to_expr (type=%s)" % str(type(t)))
Exception: Element "6.4" isn't recognized, and doesn't provide to_expr (type=<class 'float'>)
The core issue is that the right-hand side of the equation produces a floating-point result and PyVSC doesn't currently handle this. I receive proper results if I explicitly convert the right-hand side to an integer:
self.GroupList.sum == int(self.mThreadNum * self.mSharePercent/100)
I recommend using explicit conversion for now. In the future, I will either improve the error messaging or provide direct support for using floating-point expressions in integer constraint expressions.
from pyvsc.
The 0.8.4 release contains changes to automatically convert floating-point number used in constraints to integers. I believe this is the best way to address this issue.
Thank you for the issue report!
from pyvsc.
Related Issues (20)
- Can't have a randsz_list_t of randobj HOT 1
- ModuleNotFoundError: No module named 'pyboolector' HOT 10
- I'm not able to install pyvsc package, it fails when handling the pyboolector module HOT 3
- Selecting a list element from a list of bit-vectors returns an int HOT 3
- Setting constraint_mode to False retains the previous range/bounds of the constraint HOT 1
- Cannot make constraint under if_then soft HOT 13
- Cannot use random value as list index in a constraint HOT 2
- PicklingError when trying to pickle a VSC randobj HOT 2
- What is the relation between pyvsc and portable stimulus (pss)? HOT 2
- how to print coverage model HOT 3
- pyvsc performance dominated by stack frame operations in inspect module HOT 1
- import error _boolector_add
- Enh: Support Default bin (How to write "default" in vsc.coverpoint ?)
- install error for latest version macos HOT 3
- constraint solver error HOT 1
- Installing pyvsc fails on pyboolector for python 3.11.5 on Linux (Arch) HOT 3
- Distributions have higher priority than soft constraints HOT 1
- I can't install pyvsc for pypy3.10! HOT 4
- not_inside constraint unexpectedly reducing output set significantly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvsc.