Dejan Dozet
Dejan Dozet

Reputation: 1019

Why the @objective value is negative?

I have this model and I am using cbc:

    @variable(premex, PRODAMOUNT[op_k in keys(_ORDER_PRODUCTs_ALL), u_k in keys(UNITS), t in TIME], Int, lower_bound = 0)

    @objective(
        premex,
        Min,
        sum(
            sum(
                    (
                        (iszero(
                                sum(
                                    PRODAMOUNT[op_k, u_k, t] * _PRODUCTs_ALL[op["product"]]["bagSize"] 
                                    for (op_k, op) in _ORDER_PRODUCTs_ALL
                                )
                            ) ? 0 : u["cap"]
                        ) - 
                        sum(
                            PRODAMOUNT[op_k, u_k, t] * _PRODUCTs_ALL[op["product"]]["bagSize"] 
                            for (op_k, op) in _ORDER_PRODUCTs_ALL
                        )
                    ) * u["util_cost1"]
                    for (u_k, u) in UNITS
                )  
                for t in TIME
            )
    )

And here is a constraint that doesn't allow PRODAMOUNT on one UNIT / t to go above the max capacity of that unit.

     for t in TIME
            @constraint(
                premex, 
                [u_k in keys(UNITS)],
                sum(
                    PRODAMOUNT[op_k, u_k, t] * _PRODUCTs_ALL[op["product"]]["bagSize"]
                    for (op_k, op) in _ORDER_PRODUCTs_ALL
                    ) 
                    <= UNITS[u_k]["cap"]
            )
        end

Objective value: -461275000.00000000

How? Why the negative value?

UNITS[u_k][“cap”] and u[“cap”] are the same

Upvotes: 1

Views: 307

Answers (1)

Oscar Dowson
Oscar Dowson

Reputation: 2574

Please provide a link when cross posting: https://discourse.julialang.org/t/why-the-objective-value-is-negative/46781

Your objective function is negative because the first term evaluates to 0 prior to being passed to Cbc, leaving only the negative summation.

Upvotes: 1

Related Questions