mystic

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

Putting integer constraints in mystic

删除回忆录丶 提交于 2020-06-09 05:32:06
问题 I am new to mystic and working on an optimization problem.My mystic code looks like this: def find_loss(e,lmd,q,k): edge_pmf=find_final_dist(e,lmd,q) l_e=sum(edge_pmf[k+1:]) return l_e def objective(x): s=0 for i in range(len(x)): s+=find_loss(edge_enum[i],lamd,q,x[i]) return s added=lambda x: [i for i in x] cons=lambda x: my.constraints.impose_sum(total_cap,added(x)) @integers() def round(x): return x bounds=[(0,None)]*a if __name__=='_main_': result=diffev2(objective,x0=bounds,bounds=bounds

How to apply inequality constraints in Mystic

痴心易碎 提交于 2020-01-25 07:23:09
问题 I'm trying to maximise an objective subject to an inequality constraint using Mystic but am struggling to see how to apply the penalty constraints. The problem is non-convex and involves maximising the objective where there is only one variable that will be changing (x). I'm trying Mystic because I've heard that it is good for large scale optimisation, and x is a 1D array contain millions of items (size N). There are three 1-D arrays of numbers a, b, and c all with N number of values, (the

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