constraints

Python pandas: can I add constraints like I would in a database?

一个人想着一个人 提交于 2019-12-12 00:29:26
问题 Is there any way to add constraints or foreign keys the way I would in a database? E.g. making sure a field is unique, a field is always > 0, that customer_id in the orders table always has a match in customer_id in the customer table, etc? 来源: https://stackoverflow.com/questions/32353732/python-pandas-can-i-add-constraints-like-i-would-in-a-database

conditional constraint in optimization

夙愿已清 提交于 2019-12-12 00:04:22
问题 Does anybody know how to write conditional constraint in mixed integer programming for this case: if a == 0 then b = 1 else b = 0 -M <= a <= M b={0,1} Note that M can be any continuous number. Thanks. Regards, 回答1: I would approach this as follows. First use a variable splitting approach by introducing two non-negative variables aplus, amin : 0 <= aplus <= d*M 0 <= amin <= (1-d)*M a = aplus-amin d in {0,1} Now we can do: 0.001*(1-b) <= aplus + amin <= M*(1-b) In many cases we can simplify

Optaplanner add computerroom restriction

情到浓时终转凉″ 提交于 2019-12-11 22:29:54
问题 it's my first post here and I'm posting for my team of learning Java programmer for an school project. So we aren't good programmer. how can I add a constraint to make the Optaplanner move the lectures into a specific room type. For example I want to move the lecture "Programming" into a computerroom and the lecture "Math" in a normal room. But with my constraint it declares the hard constraints but doesn't move the lectures in their room. This should be a negative constraint. So the negative

How to set multiplier for the UIImageView

╄→гoц情女王★ 提交于 2019-12-11 21:04:45
问题 I have an image whose width = 189, height = 41, so I defined 2 constraints for this UIImageView like this: NSArray *constraint_V=[NSLayoutConstraint constraintsWithVisualFormat:@"V:[Title(41)]" options:0 metrics:nil views:viewsDictionary]; [imgVwLogo addConstraints:constraint_V]; NSArray *constraint_H=[NSLayoutConstraint constraintsWithVisualFormat:@"H:[Title(189)]" options:0 metrics:nil views:viewsDictionary]; [imgVwLogo addConstraints:constraint_H]; It looks good on iPhone 4s, but when it

Looking for SQL constraint: SELECT COUNT(*) from tBoss < 2

亡梦爱人 提交于 2019-12-11 20:55:29
问题 I'd like to limit the entries in a table. Let's say in table tBoss . Is there a SQL constraint that checks how many tuples are currently in the table? Like SELECT COUNT(*) from tBoss < 2 Firebird says: Invalid token. Dynamic SQL Error. SQL error code = -104. Token unknown - line 3, column 8. SELECT. Thanks. Norbert 回答1: Does your database have triggers? If so, Add a trigger that rolls back any insert that would add more than 2 rows... Create Trigger MyTrigName For Insert On tBoss As If

Using UIImageView together with constraints

独自空忆成欢 提交于 2019-12-11 20:42:19
问题 I've a UIImageView that holds a profile image in my app. The aspect is "Aspect Fit". But I have some problems. I've pinned a contraint from the UIImageView to the larger UImageView above and with the leading space to superView. but it looks like this on runtime: Way too big and placed wrongly. It also looks like this in IB: What should I be doing to achieve the right behaviour here? Thanks! Erik 回答1: You image view is resizing itself based on the image you set it to display. This behaviour

Generically identify the rowid causing a constraint conflict in SQLite

亡梦爱人 提交于 2019-12-11 19:48:31
问题 I need to identify the row that caused a constraint check to fail after an INSERT OR IGNORE statement. I need this for a tool that generates SQL statements, so I can't tie this to a specific use case with a particular table. The challenge here is that I can't know which constraints are set for the particular table that I will insert into. It may have foreign key or UNIQUE constraints, or even a CHECK clause attached. So, all I can learn from the INSERT is that it has failed. Now, how to I

Issues regarding constraint's setting via mystic package

≡放荡痞女 提交于 2019-12-11 18:31:40
问题 I am trying to set constraints to perform optimization with the help of mystic package. I executed the code in Spyder and PyCharm IDE. In both cases kernel crashed. When I have only 2 line string 'simplify'-method works fine. Trying to set greater than 2 lines constraints leads to kernel's death. import mystic.symbolic as ms equation = """ x0*7.2 + x1*1.9 + x2*35.7 + x3*4.1 + x4*23.0 + x5*19.2 + x6*0.0 + x7*0.0 + x8*0.0 + x9*0.0 + x10*10.1 + x11*10.8 + x12*11.3 + x13*14.8 + x14*78.6 + x15*5.8

How to prevent tree having circular references

夙愿已清 提交于 2019-12-11 17:23:37
问题 original table is more complicated but.. i got a table which stores great many trees inside like; what im looking is a nontrigger mothod like constraint or a trigger which decides to rollback very fast.. create table myTreeTable ( id int not null identity(1,1), node varchar(80), parent varchar(80), constraint PK_mytable primary key nonclustered (node) ) insert into myTreeTable values ('a', null) insert into myTreeTable values ('b', 'a') insert into myTreeTable values ('c', 'a') insert into

Unique constraint without index

社会主义新天地 提交于 2019-12-11 17:08:47
问题 let's say I have a large table. This table not need to be queried, I just want to save the data inside for a while. I want to prevent duplicates rows in the table, so I want to add an unique constraint (or PK) on the table. But the auto-created unique index is realy unnecessary. I don't need it, and it's just wasting space in disk and require a maintenance (regardless of the long time to create it). Is there a way to create an unique constraint without index (any index - unique or nonunique)?