Closed data25 closed 4 years ago
Can you either post the code above as actual text (see this )or try to create a minimum working example (MWE)? Nothing looks obviously wrong at the moment.
Hi, here is the code.
import numpy as np
import math
from gpkit import Variable, Model, SignomialsEnabled
#Decision variables
C_D = Variable("C_D", "-", "Drag coefficient")
C_L = Variable("C_L", "-", "Lift coefficent")
a = Variable("a", "-", "coefficient a")
b = Variable("b", "-", "coefficient b")
c = Variable("c", "-", "coefficient c")
alpha = Variable("alpha", "-", "angle of attack")
objective = C_D/C_L #to maximize cl/cd, we minimize its reciprocal
#Enabling signomials for subtraction
with SignomialsEnabled():
constraints = [1<=0.00929839*(C_L**4.13477/C_D**0.0213768)+0.904471*(C_L**0.00219711/C_D**0.0213768)+1.4992e-06*(C_L**50.9294/C_D**0.0213768), 1<=(math.pi/C_L)*(2*alpha-15*(a/4)+3*b-2*c), 1<=a*(15/0.00004)-3*(b/0.00001)+2*(c/0.00001), 1>=0.0000001/C_D, -1>=(20/alpha), 1<=(20/alpha), 1>=(0.00001/a), 1<=(0.080780/a), 1<=(0.147875/b), 1>=(0.00001/b), 1>=(0.00001/c), 1<=(0.067095/c)]
m = Model(objective, constraints)
sol = m.localsolve(verbosity=0) #uses 'cvxopt'
print(sol.summary())
You do realize that you have a -1 >= signomial constraint for alpha, right? This is not possible by definition of the GP, since signomials and variables are restricted to the positive orthant.
Once you fix that issue, the model closes no problem. The way to overcome the negative variable issue is to create an offset (alpha=1 is actually -6 etc) or add other dummy variables. I hope this helps.
thanks! it did work. the -1 was a typo.
Above is the snippet of my code of a Signomial problem. While executing the code, i get the error "Cannot initialize SignomialInequality outside of SignomialsEnabled environment". I am not sure if i am missing anything. Help is much appreciated.
Thanks