8,974 questions
13
votes
4
answers
1k
views
Why doesn't C++ allow virtual function overrides to be constrained by a concept/requires clause?
I tried to write the following code and it was rejected by the compiler:
#include <type_traits>
struct Base {
virtual void f() {}
};
template <typename T>
struct Derived : Base {
...
Advice
0
votes
3
replies
86
views
PostgreSQL, unique on combination of two columns
In PostgreSQL, it is easy to set a uniqueness constraint for two columns using CONSTRAINT UNIQUE.
For example
CREATE TABLE someTable (
id serial PRIMARY KEY,
col1 int NOT NULL,
col2 int ...
-2
votes
1
answer
86
views
Adding CHECK Constraint Without Error and Duplication [duplicate]
I have implemented this code to add a check constraint after creating the table
ALTER TABLE recruitment_data.candidate_experiences
ADD CONSTRAINT chk_experience_dates
CHECK ( ...
3
votes
2
answers
141
views
How to properly constrain two-dimensional array types to be square in Ada?
I'm trying to create a package of generic adjacency matrices to define graphs, and the first goal is to define a static version based on two-dimensional array:
with Ada.Containers.Vectors;
generic
...
0
votes
0
answers
74
views
Composite key (ts, deviceid) with timeseries container
I’m on GridDB Cloud (Free). For a TimeSeries container, I want each device to have at most one row per timestamp, i.e., enforce uniqueness on (ts, deviceid).
Schema:
CREATE TABLE TSDB (
ts TIMESTAMP ...
-2
votes
2
answers
148
views
Split N people in X constrained groups with Google Sheets
[EDIT]
Hi everyone,
I am looking for clues to work out a sorting formula with Sheets.
We are planning "teambuilding" school trips at our international college. I need to split a list of 200+ ...
6
votes
2
answers
192
views
Enforce CRTP via Constraint in C++
I'd like to enforce a CRTP template parameter to be an actual derived type. Unfortunately it seems to be impossible to express that as a constraint.
The problem is that the constrained type is ...
0
votes
1
answer
64
views
System verilog constraint for queues with fixed number of 6s
Can someone help me with system verilog constraint for the below requirement.1) Fixed queue size of 10 and has four 6s in it at random position.
I tried the below constraint to start with.
class ...
1
vote
1
answer
75
views
Adding constraints to deriving declarations
I have this datatype
newtype Dimension a b = MkDimension b
Whenever it is properly formatted (e.g. satisfies the format constraint), I want to derive a set of classes. I do not want a Dimension which ...
0
votes
2
answers
83
views
How to make UIView fit the size of its contents?
I have the following code
func setupUI() {
self.view.backgroundColor = .white
let titleLbl = UILabel()
titleLbl.text = book.title
titleLbl.textColor = .black
...
1
vote
0
answers
32
views
How can you use GRASP to solve a bi-objective optimization problem (in assembly line balancing)?
My problem is:
I have to optimize my collaborative assembly line with solving a bi-objective optimization model using metaheuristics. We chose to start with GRASP.
The two objectives are to minimize ...
1
vote
1
answer
121
views
Why is this Deferred Constraint Trigger Raising an Exception on the Not Final State of the Record
Why is my deferred constraint checking an intermediate state and not the final state of the record?
We use PostgreSQL 16.9 for our database and we use Python3 and Psycopg2 to manage our data pipeline.
...
4
votes
3
answers
128
views
Why can't Haskell unify my types when using a constraint as class parameter?
I am trying to split my code into nice modules. However, while doing this, one of the classes I have in the imported module (Outer in Module 1 below) needs a constraint that is only known in the ...
2
votes
2
answers
152
views
Use function on foreign key constraint
Can I have a foreign key constraint that takes a timestamp column but uses it as date only?
I'm trying something like this but it doesn't work:
alter table
table1
add
constraint my_constraint ...
4
votes
1
answer
73
views
Constrained type is unconstrained?
I've been writing Rust for a several months now, and I've come across this headscratcher:
I have the following code:
trait MyTrait {}
impl MyTrait for String {}
impl MyTrait for str {}
impl MyTrait ...
0
votes
0
answers
48
views
Bayesian model in SAS Proc MCMC - how to specify parameter constraints
I am trying to estimate a Bayesian logistic model (with a latent variable and two comparison groups, apart from model parameters), while specifying that two parameters should be equal. My SAS code ...
0
votes
0
answers
25
views
How to add unique constraint in multiple column?
example: I have a clazz table, with name and package name, the two columns need unique together.
class clazz {
long id; // primary key
QString name; // class ...
0
votes
1
answer
99
views
How to do a negative foreign key check (constraint to foreign table) in MySQL?
I want to make sure, that a column doesn't have a value that exists in another column of another table. It is kind of like a negative foreign key check, if you will.
However adding a constraint doesn'...
1
vote
1
answer
40
views
database implementation constraints and documentation
a constraint requires me that.
"the value of B, present in table B1, must always be less than that of A present in table C1".
is it correct to implement two triggers to do this?
one that is ...
2
votes
1
answer
136
views
How do conditionally apply field constraints based on value type in pydantic v2?
I have this pydantic model with a field, and this field could be either an int or a non numeric value like a str or list.
from pydantic import BaseModel, Field
class Foo(BaseModel):
bar: str | ...
1
vote
3
answers
235
views
Unique constraint to prevent overlapping ranges? To make sure a BETWEEN statement for two columns will always only return one row?
We have two columns, id_begins and id_ends. We use a BETWEEN statement to select the row where a specific id number will fit between the values in those two fields (including the begins and ends ...
0
votes
1
answer
44
views
Error on database migration - Failed to add the foreign key constraint [duplicate]
I'm trying to migrate a MS-Access DB into MySql using MySQL Workbench. During the migration I get a "Failed to add the foreign key constraint. Missing index for constraint 'RegistrationsInvoices' ...
1
vote
1
answer
83
views
Setting a predecessor constraint in timefold python
I am trying to implement a predecessor constraint similar to the Job Scheduling example given in java.
But I struggle with the ordering constraint definition to consider predecessors.
I have defined ...
5
votes
1
answer
111
views
How to constrain template methods to match class template parameters?
I have a following class:
template<typename Population, typename... Operators> class GA
{
public:
template<typename Evaluator,
typename std::enable_if_t<
std::...
0
votes
4
answers
201
views
Minzinc Constraint Question - Sudoku similar
I'm new to Minizinc, and I want to solve the following problem.
I have a given matrix of 6x6 cells. Rows are numbered from 1..6, columns from A..B.
All cells shall be filled with digits from 1..9 by ...
-2
votes
2
answers
69
views
Database design for storing historical and future dated data? [closed]
I have a requirement to create a system for storing organization information. My client does re-organization maybe once a year and changes the names and codes of the organization. There are cases ...
0
votes
1
answer
33
views
Prevent duplicate use of value for another primary key?
I have this table that stores historical data of a record. Any update even with code and name fields should insert a new record of the same id but may have different values for code, name and ...
2
votes
1
answer
113
views
What kind of value do you get when you apply “return” to a value without a constraint?
If you apply return to 'a' you get a value of type m Char, belonging to the Monad class: :t return 'a' → return 'a' :: Monad m => m Char. If you apply the resulting value to some other value, say, ...
2
votes
1
answer
53
views
Writing an independent routine to add a minimization constraint in solnl()
I need to find a way to write an independent routine to add a particular constraint to a minimization problem in solnl()
With a concrete example, one has this
##### for optimization
library(MASS)
...
1
vote
1
answer
82
views
Constraint-based optimizing the decision threshold of a prediction model
I am working on optimizing the decision threshold of a trained decision model for a binary case (targets 0 and 1). I want to optimize the decision threshold of the model, i.e. the point at which the ...
2
votes
1
answer
137
views
How to correctly specify lower and upper bounds in mgcv mono.con function
In the documentation for mgcv::pcls(), an example of constructing a monotonically increasing gam model is provided with the following code:
set.seed(1234) # added for reproducibility in this post only
...
2
votes
1
answer
87
views
Constrain a table value based on another table in SQL Server?
I have four tables (simplified)
CREATE TABLE ProductDetails
(
ProductID int,
ProductName varchar(50),
CONSTRAINT PK_ProductDetails PRIMARY KEY (ProductID)
);
CREATE TABLE CaseDetails -- ...
2
votes
0
answers
54
views
Can Haskell express negative class constraint (such as two types are _not_ the same)? [duplicate]
One can express (a ~ b), but can one write something like (a !~ b)?
My hunch is that no, since in a handwawy way constraint resolution is analogous to search, and one can't conclusively say there's no ...
1
vote
1
answer
86
views
devise and language by multiple domain
I'm trying to use multi language by domain, for example I have domain.fi.local for language Finnish and domain.es.local for language Spanish and on every of them you can switch to English and I have ...
-1
votes
1
answer
68
views
Offset view containing horizontally scrollable collection view in superview, while also allowing to scroll to edges of superview
I am working with UIKit.
I have a main view that contains a few stack views + few label views + a horizontally scrollable collection view.
I am then adding this main view to a superview.
I would like ...
1
vote
0
answers
53
views
Interdependent bounds in scipy minimize
Say I have a function f(x,y,z) I want to minimize using scipy.optimize.minimize. I want to minimize it subject to the constraint x < y < z.
I don't think I can use the bounds argument to do this ...
0
votes
1
answer
132
views
How can I use ALTER TABLE to add a column that is NOT NULL and REFERENCES?
I want to add a column of type TEXT, NOT NULL, with a DEFAULT value of empty string, which should reference a column in a different table. I can add foreign key references when creating a table.
But ...
7
votes
1
answer
86
views
Adding bot turn costs to A* search in pathfinding within a grid
I have an NxM grid of square cells. traversal can only happen in North, South, East and West directions in the cells. Some of the cells are blocked and cannot be traversed.
A bot is given a start and ...
1
vote
5
answers
399
views
Constraints for Hitori puzzle
The Hitori puzzle consists of an nxn grid filled with numbers 1..n, some of them repeated in rows and/or columns. The goal is to cover some of the repeated numbers so that
i) there are no repeated ...
0
votes
1
answer
74
views
Python Pulp LP leaving rooms unassigned and penalties/constraints not preventing that
I am having difficulty getting all classrooms to be assigned to a class for a room assignment problem. I am using a grid calculated based on class capacity & room capacity (values 0-1). ...
0
votes
0
answers
55
views
Constrained HMM Learning with hmmlearn
I am trying to train a constrained Hidden Markov Model using the hmmlearn package but I faced some issues.
I override the CategoricalHMM class and set certain transitions to 0 after each M-step as ...
0
votes
1
answer
39
views
Logic Puzzle: Normalize elements of array with minimum and maximum constraints
The sum of the elements of an array needs to be one while the elements adhere to certain maximum and minimum constraints. If the element is smaller than the minimum allowed value, it element may be ...
0
votes
0
answers
25
views
Is there a way to validate value passed to annotation applied to concrete class implementations during annotation processing phase
I have an abstract class that consumers of my library are expected to implement:
public abstract class StatusIndicator {
protected StatusIndicator(Class<? extends StatusIndicator> thisClass) {
...
0
votes
0
answers
19
views
Does JpaBuddy supports ImplicitNamingStrategy of Hibernate in Liquibase Generation?
We would like to control the naming of contraints when JpaBuddy generates Liquibase from Jpa Entities. When I add the names explicitly e.g. via @ForeignKey JpaBuddy makes them upper case what I don't ...
1
vote
1
answer
118
views
How can I check if a generic enum has value?
In my C# application, I have an abstract class that is a wrapper around UnitsNet library to group closely related properties (such as a numeric value and unit for that value that user has chosen), to ...
0
votes
0
answers
50
views
MySQL UNIQUE still allows duplicate row insert when foreign key columns are NULL [duplicate]
I Have 3 tables ProdVariant, Variant, VariantValues.
ProductVariant
----------------------------
ProductVariantID PK
ProductID FK NOT NULL
VariantID FK NULL
...
1
vote
1
answer
87
views
Difference between declarations of trait bounds
I'm building myself a parsing library, and I found a key distinction between two types of declared trait bounds.
Take the following trait:
pub trait Parsable: FromStr<Err: Display>
{}
With this,...
0
votes
0
answers
37
views
How to apply OLS with constraints on coefficients and align the output scale with the target variable?
I am working on an OLS regression problem where:
The dependent variable (target) ranges from 1 to 6 (with steps of 1).
The independent variables range from 1 to 10 (with steps of 0.5).
I want to set ...
0
votes
1
answer
1k
views
PostgreSQL SET session_replication_role = replica not bypassing constraints in Supabase seed file
I'm trying to seed data into my Supabase database but even though my seed.sql (generated by Supabase) includes SET session_replication_role = replica at the top, constraints are still being enforced. ...
0
votes
0
answers
71
views
How to properly enforce consecutive time slot constraints in a constraint programming timetable software?
Problem Description
I am trying to add a constraint to my scheduling optimization problem to ensure that generated timetables have consecutive hours (i.e., no gaps between time slots within a day). ...