constraints

Strange behaviour of eval() with lambda functions inside a loop in python

冷暖自知 提交于 2020-05-15 09:55:26
问题 I have a string input file as below (one equation per line): 1.0 - x[0] - x[1] x[0] + x[1] I am trying to convert these equations to lambda functions using eval() in python and then use them in an optimization scheme. Here is what I do: def gen_const(input): list = input.read_eqs() for i in list: m = lambda x: eval(i) cons.extend([{'type': 'ineq', 'fun': m}]) return cons This cons fails when it is used inside the optimization scheme. However, if I only consider the first round inside the loop

GEKKO - optimization in matrix form

这一生的挚爱 提交于 2020-05-15 02:44:05
问题 I am trying to solve an optimization problem where I need to specify the problem and the constraints using a 2D matrix. I have been using SCIPY, where the 1D arrays are the requirements. I want to check if GEKKO allows one to specify the objective function, bounds and constraints using a 2D matrix. I have provided details and a reproducible version of the problem in the post here: SCIPY - building constraints without listing each variable separately Thanks C 回答1: You can use the m.Array

How to create a unique index with conditional and subquery in PostgreSQL?

China☆狼群 提交于 2020-05-13 19:16:46
问题 I use PGSQL and try add the index below. CREATE UNIQUE INDEX fk_client ON user_client (fk_client) WHERE fk_client NOT IN(SELECT fk_client FROM legal_entity); But ... It is not possible, because there is allowed run a sub query in the creation of an index. I get the following error: ERROR: cannot use subquery in index predicate Is there any way to solve this problem? The above model Represents the situation of the case. The client Can Be either an ordinary person, or a company If an ordinary

Swift programmatically-added constraints dont work

不羁岁月 提交于 2020-04-30 06:46:07
问题 I have a view inside a scrollview: Now I want to add the child views to that view programmatically. Thats my code to do that: Child view (works) //Adds header to the view again because it was removed in the clear() method //Header is just a label lv.addSubview(header) header.leadingAnchor.constraint(equalTo: header.superview!.leadingAnchor).isActive = true header.topAnchor.constraint(equalTo: header.superview!.topAnchor, constant: 2).isActive = true header.widthAnchor.constraint(equalTo:

How to automatize constraints definition on PuLP?

天大地大妈咪最大 提交于 2020-04-18 06:12:54
问题 Supply Chain Optimization - PuLP & Python 1. Problem definition I'm trying yo optimize how I define my constraints in the model shown below. Right now, I need to create different constraints for each year because otherwise the algorithm doesn't provide the expected result. I would like to have for "case" constraint a single definition, instead of define one for each year. Where "case" is: model += (((units_ind[str(1), str(manuf), str('B'), str(option)]) + units_ind[str(1), str(manuf), str('V'

Get UIView height and use it for its own constraints

♀尐吖头ヾ 提交于 2020-04-16 05:47:12
问题 How can I can the height of my UIView before it is actually presented? This is what I tried: print(wishWishView.frame.size.height) self.view.addSubview(self.wishWishView) wishWishView.leadingAnchor.constraint(equalTo: self.view.leadingAnchor).isActive = true wishWishView.trailingAnchor.constraint(equalTo: self.view.trailingAnchor).isActive = true wishWishConstraint = wishWishView.topAnchor.constraint(equalTo: self.view.bottomAnchor) wishWishConstraint.isActive = true UIView.animate

How can we add Views dynamically androidx.constraintlayout.helper.widget.Flow and add reference Ids

我与影子孤独终老i 提交于 2020-04-13 04:58:07
问题 How can we add Views dynamically in androidx.constraintlayout.helper.widget.Flow and add reference Ids dynamically. 回答1: Here is Kotlin Implementation for (i in 0..4) { val customView = CustomComponent (this) customView.id = generateViewId() constraintLayout.addView(customView,i) flow.addView(customView) } Following is my XML <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/constraintLayout" app:layout

IOS8 Autolayout with relative width / height

不羁的心 提交于 2020-04-11 05:09:11
问题 I need to autolayout a storyboard UIView with a single UIControl. The UIControl should be centered, needs to have a aspect ratio of 1:1 and should always use 90% of the superviews width or height depending on the device orientation without clipping. I added 4 constraints Center Y Alignment - View - Superview Center X Alignment - View - Superview Equal Widths - View - Superview with multiplier set to 0.9 Aspect Ratio - View - View with multiplier set to 1:1 This setup works fine in portrait

oracle sql defer VS disable

a 夏天 提交于 2020-03-28 06:40:44
问题 In oracle sql, setting a constraint to deferred VS disabling a constraint seem to have similar functionalities. Are there any significant differences between the two? It would be much appreciated if you can illustrate their uses with real world scenarios. thanks 回答1: A disabled constraint is one that's defined in the database but not enforced at all. (Like dropping a constraint only it's easier to switch back on.) As for deferrable: http://docs.oracle.com/cd/E18283_01/server.112/e16508

How I can define this constraint?

百般思念 提交于 2020-03-23 14:33:18
问题 I am designing a database for a parking lot in Postgres. I need to define a constraint (or similar) to verify the Id_Lot in Ticket is empty in the table "Lot" . How I can do it? The relevant tables are: Ticket: "Id_Ticket" serial PRIMARY KEY, "Date_Entrance" date NOT NULL, "Time_Entrance" time without time zone NOT NULL, "License_plate" varchar(6) NOT NULL references "Vehicle"("L_Plate"), "Id_Lot" varchar(4) NOT NULL references "Lot"("Code") Lot: "Code" varchar(4) NOT NULL PRIMARY KEY, "Type"