constraints

How to add programmatic constraints to a UITableView?

我怕爱的太早我们不能终老 提交于 2021-02-19 03:38:24
问题 I have a class set up as follows: class SettingsController: UITableViewController { I would like to be able to add constraints to the UITableView so that there is equal spacing either side of the table (it is currently a full width table, so a little ugly on iPad). I have read that I can't add constraints to a UITableViewController , and instead I must add a UIViewController to my class, add a UITableView to that, and then I should be able to add the constraints to the TableView. I've amended

Remove Unique constraint on a column in sqlite database

家住魔仙堡 提交于 2021-02-19 02:24:06
问题 I am trying to remove a UNIQUE constraint on a column for sqlite but I do not have the name to remove the constraint. How can I find the name of the UNIQUE constraint name to remove it. Below is the schema I see for the table I want to remove the constraint UNIQUE (datasource_name) sqlite> .schema datasources CREATE TABLE "datasources" ( created_on DATETIME NOT NULL, changed_on DATETIME NOT NULL, id INTEGER NOT NULL, datasource_name VARCHAR(255), is_featured BOOLEAN, is_hidden BOOLEAN,

How to conditionally invoke a generic method with constraints? [duplicate]

让人想犯罪 __ 提交于 2021-02-17 08:27:34
问题 This question already has answers here : How do I use reflection to call a generic method? (8 answers) Closed 6 years ago . Suppose I have an unconstrained generic method that works on all types supporting equality. It performs pairwise equality checks and so works in O(n 2 ) : public static int CountDuplicates<T>(IList<T> list) { /* ... */ } I also have a constrained generic method that only works with types supporting sorting. It starts from sorting the list in O(n log n) , and then counts

Unable to constrain generic type

不羁岁月 提交于 2021-02-16 21:19:14
问题 I can't figure out what's happening here. I'm building a wrapper for a Dictionary collection. The idea is that, when the size of the collection is small, it will use a normal in-memory Dictionary; but, when a threshold number of items is reached, it will internally switch to an on-disk Dictionary (I'm using the ManagedEsent PersistentDictionary class). A snippet of the on-disk version is below. When compiling, it fails with the following error: "The type 'T_KEY' cannot be used as type

Unable to constrain generic type

萝らか妹 提交于 2021-02-16 21:17:08
问题 I can't figure out what's happening here. I'm building a wrapper for a Dictionary collection. The idea is that, when the size of the collection is small, it will use a normal in-memory Dictionary; but, when a threshold number of items is reached, it will internally switch to an on-disk Dictionary (I'm using the ManagedEsent PersistentDictionary class). A snippet of the on-disk version is below. When compiling, it fails with the following error: "The type 'T_KEY' cannot be used as type

Pyomo: Struggling to get a constraint to work

一笑奈何 提交于 2021-02-11 14:34:05
问题 I am trying to model an Electric Vehicle scheduling to minimise the electricity bill. Of course, the EV will only be able to charge every time that is plugged into a charging station (i.e. it cannnot charge when the vehicle is driving). Basically, it is a stationary battery that can be disconnected and connected again. I already managed to model a stationary battery scheduling before and is working good as I expected, however I am having a hard time setting up a constraint to connect and

Minimizing non-convex function with linear constraint and bound in mystic

99封情书 提交于 2021-02-11 14:19:12
问题 Say I have a non-convex objective function loss that takes a np.ndarray named X whose shape is (n,) and returns a float number. The objective has many many many local minima, since it's essentially a function of np.round(X * c, 2) where c is another constant array of shape (n,). You can imagine something like this: def loss(X: np.ndarray) -> float: c = np.array([0.1, 0.5, -0.8, 7.0, 0.0]) X_rounded = np.round(X * c, 2) return rosen(X_rounded) The linear constraint is expressed with two

How to fix some dimensions of a kernel lengthscale in gpflow?

我只是一个虾纸丫 提交于 2021-02-11 04:54:12
问题 I have a 2d kernel, k = gpflow.kernels.RBF(lengthscales=[24*5,1e-5]) m = gpflow.models.GPR(data=(X,Y), kernel=k, mean_function=None) and I want to fix the lengthscale in the 2nd dimension, and just optimise the other. I can disable all lengthscale optimisation using, gpflow.set_trainable(m.kernel.lengthscales, False) but I can't pass just one dimension to this method. In GPy we would call m.kern.lengthscale[1:].fixed() or something. Maybe I could use a transform to roughly achieve this (e.g.

How to fix some dimensions of a kernel lengthscale in gpflow?

99封情书 提交于 2021-02-11 04:53:22
问题 I have a 2d kernel, k = gpflow.kernels.RBF(lengthscales=[24*5,1e-5]) m = gpflow.models.GPR(data=(X,Y), kernel=k, mean_function=None) and I want to fix the lengthscale in the 2nd dimension, and just optimise the other. I can disable all lengthscale optimisation using, gpflow.set_trainable(m.kernel.lengthscales, False) but I can't pass just one dimension to this method. In GPy we would call m.kern.lengthscale[1:].fixed() or something. Maybe I could use a transform to roughly achieve this (e.g.

How to fix some dimensions of a kernel lengthscale in gpflow?

余生颓废 提交于 2021-02-11 04:52:08
问题 I have a 2d kernel, k = gpflow.kernels.RBF(lengthscales=[24*5,1e-5]) m = gpflow.models.GPR(data=(X,Y), kernel=k, mean_function=None) and I want to fix the lengthscale in the 2nd dimension, and just optimise the other. I can disable all lengthscale optimisation using, gpflow.set_trainable(m.kernel.lengthscales, False) but I can't pass just one dimension to this method. In GPy we would call m.kern.lengthscale[1:].fixed() or something. Maybe I could use a transform to roughly achieve this (e.g.