# Question:LPSolve Matrix Form

## Question:LPSolve Matrix Form

Maple 13

Ok, I want to solve the below code as fast and efficient as possible.
Since it is an LP problem LPSolve(Matrix Form) should be the best.

The problem is that the default objective function in LPSolve(Matrix Form)
is c'x which creates a bit of a problem since my objective function is not a
function of x. My objective function is simply ur + dr. How can I solve that?!

restart:
randomize():
with(Optimization):
with(Statistics):
with(LinearAlgebra):

N := 50:
W := Vector(N, symbol = w):
R := RandomMatrix(N, outputoptions = [datatype = float[8]]):
ER := Vector[column]([seq(ExpectedValue(Column(R, j)), j = 1 .. N)]):
S := Vector(N, fill = 1, datatype = float[8]):
z := Multiply(R, Matrix(W)):

con1 := Transpose(W).S = 1:
con2 := seq(w[i] >= 0, i = 1 .. N):
con3 := seq(w[i] <= 1, i = 1 .. N):
con4 := seq(z[i][1] >= dr, i = 1 .. N):
con5 := expand(Transpose(W).ER) >= ur:

LPSolve(ur+dr, {con1, con2, con3, con4, con5}, maximize = true):

This has been branched into the following page(s):
﻿