Why the @objective value is negative?

I have this model (using cbc solver):


        @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
                )
        )

            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 negative value?

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

Because you haven’t fixed the iszero issue: Condition in @objective - #5 by odow

Look at your objective function use objective_function(premex). It won’t be what you think it is.

1 Like

Oh, this with Objective value is so confusing, but thanx for clarifying this for me too. I am not using iszero any more.