Linear Programming with vector/matrix variables

78 views
Skip to first unread message

Mostafa

unread,
Aug 31, 2017, 8:07:56 PM8/31/17
to Scala Breeze
Dear all,

I am trying to solve a linear programming problem, something similar to https://github.com/scalanlp/breeze/wiki/Quickstart#breezeoptimizelinear
However, I want to have one vector for all three optimization variables; i.e instead of:
val x0 = Real()
val x1 = Real()
val x2 = Real()
have something like  
val x = DenseVector.fill(3)(Real())
val c = DenseVector[Double](1,2,3)
but I can't seem to be able to get this part:
val lpp =  ( (x0 +  x1 * 2 + x2 * 3 )
    subjectTo ( x0 * -1 + x1 + x2 <= 20)
    subjectTo ( x0 - x1 * 3 + x2 <= 30)
    subjectTo ( x0 <= 40 )
)
right. For example first line:
(x0 +  x1 * 2 + x2 * 3 )
can't be translated to c * x. What is the right approach here?

Thank you

Mostafa 

David Hall

unread,
Sep 5, 2017, 6:43:39 PM9/5/17
to scala-...@googlegroups.com
Sorry for the slow response. There's not a way to do that currently. You can manually write the loops (or use zip and map...) if you want.

--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze+unsubscribe@googlegroups.com.
To post to this group, send email to scala-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/20cd9798-cbe7-4df7-b947-6c60e24a5fbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mostafa

unread,
Sep 5, 2017, 7:31:04 PM9/5/17
to Scala Breeze
Thank you David!
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages