简体   繁体   中英

Is it possible to identify unbounded variables?

While attempting to solve my mathematical program, I get the following error

IPOPT terminated after exceeding the maximum iteration limit.  Hint: Remember that IPOPT is an interior-point method and performs badly if any variables are unbounded.

(I'm using IPOPT because I think it is the only free solver available)

Is there any way to identify which variables are unbounded in order to help debug the issue?

Drake's MathematicalProgram returns all the bounds in bounding_box_constraints() function, you could query each of the bounding box constraint and get the bounds on the variables. Here is the python code

# We will store the lower and upper bound of each variable in x_lo and x_up.
x_lo = np.full((prog.num_vars(),), -np.inf)
x_up = np.full((prog.num_vars(),), np.inf)
for bb_con in prog.bounding_box_constraints():
    # loop over each bounding box constraint
    for i in range(bb_con.variables().shape[0]):
        # loop over each variable associated with the constraint. First find the index of the variable
        var_index = int(prog.decision_variable_index()[bb_con.variables()[i].get_id()])
        # Update the lower bound for the variable.
        x_lo[var_index] = np.max((x_lo[var_index], bb_con.evaluator().lower_bound()[i]))
        # Update the upper bound for the variable.
        x_up[var_index] = np.min((x_up[var_index], bb_con.evaluator().upper_bound()[i]))
# now x_lo and x_up stores the bounds for each variable
for i in range(prog.num_vars()):
    if np.isinf(x_lo[i]) and np.isinf(x_up[i]):
        # print out the variable with no lower and upper bound.
        print(prog.decision_variables()[i])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM