-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems computing degree of expressions with numpy data #87
Comments
The problem is that the objective rule is returning a 1x1 array [<pyomo.core.base.expr_coopr3._SumExpression object at 0x10a895208>] If you tweak the numpy data to use arrays of shape (n,) for vectors rather than (n,1), it fixes the problem. error = np.random.normal(0,1, size=nsample)
beta = np.random.randint(-5,5, size=nvariables+1)
model.Y = np.dot(X,beta) + error
print(model.Y.shape) # -> (500,) In the original code, the shape of |
How does this impact the expression generation? Why is Pyomo sensitive to
this difference?
…On Dec 18, 2016 4:16 PM, "Gabriel Hackebeil" ***@***.***> wrote:
The problem is that the objective rule is returning a 1x1 array
[<pyomo.core.base.expr_coopr3._SumExpression object at 0x10a895208>]
If you tweak the numpy data to use arrays of shape (n,) for vectors rather
than (n,1), it fixes the problem.
error = np.random.normal(0,1, size=nsample)
beta = np.random.randint(-5,5, size=nvariables+1)
model.Y = np.dot(X,beta) + errorprint(model.Y.shape) # -> (500,)
In the original code, the shape of model.Y that is reported is (500,1).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#87 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAsb-MvHRM78dFVu-ZOcgYq_zf8KDaWoks5rJaKigaJpZM4LQOaR>
.
|
I don't think it impacted the expression generation, per se. The operator overloading still generates the expected expression, just inside an array. If you dot a zero-based indexed variable with a flat numpy array, you will get a sum of product expressions. The fact that the original result here is a 1x1 array rather than a scalar just has to do with numpy returning an object of the correct shape based on the shapes of the arrays used in the expression. The rest of the behavior simply has to do with us not expecting a list or array to be returned from a rule, so whatever happens after that point probably is not good. |
@ghackebeil is right: the problem is not with expression generation, but rather with the error checking within the
The idea is that if adding 0 gives identity, then it must be a type that behaves like a numeric type. The problem is that the np.ndarry satisfies this test. Pyomo then adds the ndarray type to the list of known " Now, what to do? The one thing we can do is re-think native (POD) data detection occurs in
For the record, this problem is related to both #31 and #68. |
The following script returns an error that indicates that the expression system things that the Objective constraint is a constant, when it clearly isn't. Digging around, it looks like there is some confusion generated by the NumPY data types.
This code generates the following error:
And it generates the warning
In the cpxlp writer, the call
returns a value of zero for the degree!
The text was updated successfully, but these errors were encountered: