constraints

Regression with equality and inequality constrained coefficients in R

人走茶凉 提交于 2019-12-31 04:28:07
问题 I am trying to obtain estimated constrained coefficients using RSS. The beta coefficients are constrained between [0,1] and sum to 1. Additionally, my third parameter is constrained between (-1,1). Utilizing the below I can obtain a nice solution using simulated variables but when implementing the methodology on my real data set I keep arriving at a non-unique solution. In turn, I'm wondering if there is a more numerically stable way to obtain my estimated parameters. set.seed(234) k = 2 a =

Add unique constraint based on field value

删除回忆录丶 提交于 2019-12-31 04:08:27
问题 For the following table: I'd like to add a constraint that if IsBanned flag is set to true, the BannedOn field cannot be left empty (cannot be set to null). How can I do this in MySQL? Here's my CREATE syntax: CREATE TABLE IF NOT EXISTS `fa_ranking_system`.`Player` ( `PlayerID` INT NOT NULL AUTO_INCREMENT, `FK_ServerID` INT NOT NULL, `PlayerName` VARCHAR(15) NOT NULL, `RegDate` DATETIME NOT NULL, `IsBanned` TINYINT(1) NOT NULL, `LastUpdatedOn` DATETIME NOT NULL, `LastUpdatedBy` VARCHAR(20)

SQL Server check constraint failing on correct input

有些话、适合烂在心里 提交于 2019-12-31 02:18:05
问题 I'm using a check constraint on a table to restrict what values are inserted in the table.. Here's an explanation of what I'm trying to do If any Product(sedan) is associated to a specific ObjLevel (Toyota) then the same Product cannot be associated to another specific ObjLevel (Lexus) After I apply the check constraint on the table, any insert containing ObjLevel "toyota" or "lexus" fails.. create table ObjLevel( OLID int identity, Name varchar(50) not null ) insert into ObjLevel values(

Hibernate: duplicate key value violates unique constraint

穿精又带淫゛_ 提交于 2019-12-30 08:52:34
问题 I am trying to insert into a new record to my postgresql using Hibernate and Java EE. This is my model: @Entity @SuppressWarnings("serial") @Inheritance(strategy=InheritanceType.JOINED) public class BaseDesign implements Serializable { @Id @Expose @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", updatable = false, nullable = false) private Long id; @Version @Column(name = "version") private int version; @Expose @Column(name = "name") private String name; // getter and

Hibernate: duplicate key value violates unique constraint

左心房为你撑大大i 提交于 2019-12-30 08:52:11
问题 I am trying to insert into a new record to my postgresql using Hibernate and Java EE. This is my model: @Entity @SuppressWarnings("serial") @Inheritance(strategy=InheritanceType.JOINED) public class BaseDesign implements Serializable { @Id @Expose @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", updatable = false, nullable = false) private Long id; @Version @Column(name = "version") private int version; @Expose @Column(name = "name") private String name; // getter and

Struggling with simple constraints in constrOptim

此生再无相见时 提交于 2019-12-30 07:15:11
问题 I have a function in R that I wish to maximise subject to some simple constraints in optim or constrOptim , but I'm struggling to get my head around ci and ui to fit my constraints. My function is: negexpKPI <- function(alpha,beta,spend){ -sum(alpha*(1-exp(-spend/beta))) } where alpha and beta are fixed vectors, and spend is a vector of spends c(sp1,sp2,...,sp6) which I want to vary in order to maximise the output of negexpKPI . I want to constrain spend in three different ways: 1) Min and

custom simple constraint grails

拥有回忆 提交于 2019-12-30 07:08:12
问题 I would like to create a custom simple constraint (like display and editable) which I can use within my Domain class. Is it possible to extend ConstrainedProperty class? class City { String title BigDecimal latitude BigDecimal longitude Country country static constraints = { title ( blank: false, customConstraint: true ) // filter can be also be applied as attributes: [customConstraint: true] } } Somebody familiar with this case? 回答1: To create your own constraint: extend org.codehaus.groovy

SQL using trigger for constraint

佐手、 提交于 2019-12-30 06:44:20
问题 I am studying triggers and constraints. And I got a question to use trigger (To be honest, I am not really sure how to use trigger..) Let's say we have a Teachers table. And this teacher table contains teacher_id , ssn , first_name , last_name , class_time for example, |teacher_id|ssn | first_name | last_name | student_number| max_student |1 |1234 | bob | Smith | 25 |25 |2 |1235 | kim | Johnson | 24 |21 |3 |1236 | kally | Jones | 23 |22 and let's say the max number of student number will be

Is it possible to add a logic Constraint to a Foreign Key?

独自空忆成欢 提交于 2019-12-30 06:38:31
问题 I've got two tables and I've added a foreign key constraint. Kewl - works great. Now, is it possible to further constrain that relationship against some data in the parent table? Basically, I have animals in the parent table, and for the child table wishto only contain data where the parent data are .... um .. mammals. eg. Animals ^^^^^^^ AnimalId INT PK NOT NULL IDENTITY AnimalType TINYINT NOT NULL -- 1: Mammal, 2:Reptile, etc.. Name Mammals ^^^^^^^ AnimalId INT PK FK NOT NULL

C# generic constraints [duplicate]

被刻印的时光 ゝ 提交于 2019-12-30 05:55:11
问题 This question already has answers here : Is there a constraint that restricts my generic method to numeric types? (19 answers) Closed 5 years ago . Is it possible to enumerate which types that is "available" in a generic constraint? T MyMethod<t>() where T : int, double, string Why I want to do this is that I have a small evaluator engine and would like to write code like this: bool expression.Evaluate<bool>(); or int expression.Evaluate<int>(); but i want to prohibit MyCustomClass expression