Skip to content

Change the key of duals of greybox #2961

Open
@ZedongPeng

Description

@ZedongPeng

Summary

I am using cyipopt to solve Pyomo models with GreyBox. After cyipopt finds the optimal solution, it returns the optimal solution and duals. However, the key of the duals of the GreyBox is a dict(), which might not be very straightforward.
Example:

    dual : Direction=Suffix.IMPORT, Datatype=Suffix.FLOAT
        Key          : Value
               con00 : -0.19999999960153655
               con01 : -0.0
               con02 : -0.0
               con03 : -0.0
               con04 : -0.0
               con11 : -0.19999999960153658
               con12 : -0.0
               con13 : -0.0
               con14 : -0.0
               con22 : -0.19999999960153658
               con23 : -0.0
               con24 : -0.0
               con33 : -0.19999999960153658
               con34 : -0.0
               con44 : -0.19999999960153658
        my_block.egb : {'my_block.egb.output_constraints[log_det]': -0.9999999999996142}

    ipopt_zL_out : Direction=Suffix.IMPORT, Datatype=Suffix.FLOAT
        Key                           : Value
                        TotalFIM[0,0] :  -9.999970477546502e-13
                        TotalFIM[0,1] : -1.9999999959987137e-12
                        TotalFIM[0,2] : -1.9999999959987137e-12
                        TotalFIM[0,3] : -1.9999999959987137e-12
                        TotalFIM[0,4] : -1.9999999959987137e-12
                        TotalFIM[1,1] :  -9.999970477546502e-13
                        TotalFIM[1,2] : -1.9999999959987137e-12
                        TotalFIM[1,3] : -1.9999999959987137e-12
                        TotalFIM[1,4] : -1.9999999959987137e-12
                        TotalFIM[2,2] :  -9.999970477546502e-13
                        TotalFIM[2,3] : -1.9999999959987137e-12
                        TotalFIM[2,4] : -1.9999999959987137e-12
                        TotalFIM[3,3] :  -9.999970477546502e-13
                        TotalFIM[3,4] : -1.9999999959987137e-12
                        TotalFIM[4,4] :  -9.999970477546502e-13
         my_block.egb.inputs[ele_0_0] :                    -0.0
         my_block.egb.inputs[ele_0_1] :                    -0.0
         my_block.egb.inputs[ele_0_2] :                    -0.0
         my_block.egb.inputs[ele_0_3] :                    -0.0
         my_block.egb.inputs[ele_0_4] :                    -0.0
         my_block.egb.inputs[ele_1_1] :                    -0.0
         my_block.egb.inputs[ele_1_2] :                    -0.0
         my_block.egb.inputs[ele_1_3] :                    -0.0
         my_block.egb.inputs[ele_1_4] :                    -0.0
         my_block.egb.inputs[ele_2_2] :                    -0.0
         my_block.egb.inputs[ele_2_3] :                    -0.0
         my_block.egb.inputs[ele_2_4] :                    -0.0
         my_block.egb.inputs[ele_3_3] :                    -0.0
         my_block.egb.inputs[ele_3_4] :                    -0.0
         my_block.egb.inputs[ele_4_4] :                    -0.0
        my_block.egb.outputs[log_det] :                    -0.0

    ipopt_zU_out : Direction=Suffix.IMPORT, Datatype=Suffix.FLOAT
        Key                           : Value
                        TotalFIM[0,0] :    0.19999999960215062
                        TotalFIM[0,1] : 1.9999999959987137e-12
                        TotalFIM[0,2] : 1.9999999959987137e-12
                        TotalFIM[0,3] : 1.9999999959987137e-12
                        TotalFIM[0,4] : 1.9999999959987137e-12
                        TotalFIM[1,1] :    0.19999999960215062
                        TotalFIM[1,2] : 1.9999999959987137e-12
                        TotalFIM[1,3] : 1.9999999959987137e-12
                        TotalFIM[1,4] : 1.9999999959987137e-12
                        TotalFIM[2,2] :    0.19999999960215062
                        TotalFIM[2,3] : 1.9999999959987137e-12
                        TotalFIM[2,4] : 1.9999999959987137e-12
                        TotalFIM[3,3] :    0.19999999960215062
                        TotalFIM[3,4] : 1.9999999959987137e-12
                        TotalFIM[4,4] :    0.19999999960215062
         my_block.egb.inputs[ele_0_0] :                    0.0
         my_block.egb.inputs[ele_0_1] :                    0.0
         my_block.egb.inputs[ele_0_2] :                    0.0
         my_block.egb.inputs[ele_0_3] :                    0.0
         my_block.egb.inputs[ele_0_4] :                    0.0
         my_block.egb.inputs[ele_1_1] :                    0.0
         my_block.egb.inputs[ele_1_2] :                    0.0
         my_block.egb.inputs[ele_1_3] :                    0.0
         my_block.egb.inputs[ele_1_4] :                    0.0
         my_block.egb.inputs[ele_2_2] :                    0.0
         my_block.egb.inputs[ele_2_3] :                    0.0
         my_block.egb.inputs[ele_2_4] :                    0.0
         my_block.egb.inputs[ele_3_3] :                    0.0
         my_block.egb.inputs[ele_3_4] :                    0.0
         my_block.egb.inputs[ele_4_4] :                    0.0
        my_block.egb.outputs[log_det] :                    0.0

Since there is even no Object named my_block.egb.output_constraints, can we simplify the key of the duals to my_block.egb.outputs[log_det]?

    dual : Direction=Suffix.IMPORT, Datatype=Suffix.FLOAT
        Key          : Value
               con00 : -0.19999999960153655
               con01 : -0.0
               con02 : -0.0
               con03 : -0.0
               con04 : -0.0
               con11 : -0.19999999960153658
               con12 : -0.0
               con13 : -0.0
               con14 : -0.0
               con22 : -0.19999999960153658
               con23 : -0.0
               con24 : -0.0
               con33 : -0.19999999960153658
               con34 : -0.0
               con44 : -0.19999999960153658
        my_block.egb.outputs[log_det] : -0.9999999999996142

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions