Using Sqrt or Pow in Objective function

86 views
Skip to first unread message

Eamonn Maguire

unread,
Nov 2, 2017, 6:56:00 PM11/2/17
to pulp-or-discuss
Hi there,

Thanks for the great work! I'm a little stuck on one part of m objective function. I'm minimising the distances between the product of a set of features multiplied by learned weights and another given value. 

However, in my loss function, I'd like to do this 

obj_exp = LpAffineExpression()   
    
for doc_idx, doc in enumerate(documents):
        exp_doc = LpAffineExpression()       
        for f_idx,feature in enumerate(doc):
            exp_doc += weights[f_idx] * feature
    
        obj_exp +=  math.pow((1-lpSum(exp_doc)) - market_effects[doc_idx],2))

Is there any way to do this in Pulp?

Thanks! 

Stuart Mitchell

unread,
Nov 2, 2017, 6:57:37 PM11/2/17
to pulp-or...@googlegroups.com
Sorry pulp can't handle non-linear expressions.

The gurobi solver can though

Stu

--
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pulp-or-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/pulp-or-discuss.
For more options, visit https://groups.google.com/d/optout.



--
Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru

Yaron Kretchmer

unread,
Nov 3, 2017, 11:13:49 AM11/3/17
to pulp-or-discuss
sqrt/pow and non-linear. But you can approximate them using MILP, maybe that'll work for you
Reply all
Reply to author
Forward
0 new messages