# The objective function sparse is not supported by JuMP in julia

model = Model(Gurobi.Optimizer)
@objective(model, Min, DRect + 0.6DBlad + 0.6DBO)

The objective function `sparse([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,....0.00010553257427534537], 1, 721)` is not supported by JuMP.

how can i solve this problem i am using a sparse matrix for a minimization problem.

DRect, DBlad, DBO data are in sparse matrix.

What does it mean to minimize a matrix? So you mean something like

`sum(DRect + 0.6DBlad + 0.6DBO)`?

Each name of this corresponds to a sparse matrix (DRect , Blad, DBO).

Using MatLab I managed to create my cost vector and imported it to Julia.

#Cost Vector
#c = DRect + 0.6Blad+ 0.6DBO;

File = matopen(“c.mat”)
c = read(File,“c”);
close(File);

What I want is Minimize ‘‘c’’:

using JuMP, Clp,
model = Model(Clp.Optimizer)
@objective(model, Min, c)

I meant, mathematically, what does it mean to minimize a matrix?

Solvers like Gurobi and Clp all assume that the objective is a scalar expression. They cannot minimize a matrix. You need to apply some reduction operator to convert the matrix into a scalar expression.

`using JuMP, Clp`
`model = Model(Clp.Optimizer)`
`@objective(model, Min, c)`

You don’t have any variables or constraints.

Do you mean something like

``````model = Model(Clp.Optimizer)
@variable(model, x[1:length(c)] >= 0)
@objective(model, Min, c' * x)
``````

You should read Getting started with JuMP · JuMP

I think you need to step back and think about what you’re trying to achieve.

Do you have, on a piece of paper, a mathematical formulation of your problem as a (mixed-integer) linear program?

• What are the decision variables?
• What are their bounds?
• What are the constraints?
• What is the objective function?

It doesn’t make sense to minimize a vector of numbers, which is what `@objective(model, min, c)` is trying to do.

I have all the data.

My objective function and
min (DRect + 0.6* Blad+ 0.6 *DBO)

the calculation of this result (DRect + 0.6 x Blad+ 0.6 x DBO) I put it inside the vector c

I’m trying to solve it in stages, so I didn’t post the restrictions.

The problem I’m having is working with the espasa array

Thanks, with this example I managed to do something.
Now I’m going to test it here.

1 Like