Changeset 5845


Ignore:
Timestamp:
Jun 4, 2012 7:34:59 PM (7 years ago)
Author:
gabeh
Message:

NL WRITER: Fixing major bug in the NL writer (affecting certain forms of nonlinear models only) whereby incorrect summary information was written to the header section of NL files. The bug seemed to cause silent errors where solvers like Ipopt would still converge (or not), however results may have been meaningless since the internal model representation was flawed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/io/ampl/ampl.py

    r5817 r5845  
    529529        full_var_list.extend(sorted(Nonlinear_Vars_in_Objs_and_Constraints))
    530530        full_var_list.extend(sorted(Discrete_Nonlinear_Vars_in_Objs_and_Constraints))
     531        idx_nl_both = len(full_var_list)
    531532        full_var_list.extend(sorted(ConNonlinearVars))
    532533        full_var_list.extend(sorted(ConNonlinearVarsInt))
     534        idx_nl_con = len(full_var_list)
    533535        full_var_list.extend(sorted(ObjNonlinearVars))
    534536        full_var_list.extend(sorted(ObjNonlinearVarsInt))
     537        idx_nl_obj = len(full_var_list)
    535538        full_var_list.extend(sorted(LinearVars))
    536539        full_var_list.extend(sorted(LinearVarsBool))
    537540        full_var_list.extend(sorted(LinearVarsInt))
    538541
     542        if (idx_nl_obj == idx_nl_con):
     543            idx_nl_obj = idx_nl_both
     544
    539545        for var_name in full_var_list:
    540546            ampl_var_id[var_name] = var_id_ctr
    541547            var_id_ctr += 1
    542548
    543 
    544549#        end_time = time.clock()
    545550#        print (end_time - start_time)
     
    571576        nlv_both = len(Discrete_Nonlinear_Vars_in_Objs_and_Constraints)+len(Nonlinear_Vars_in_Objs_and_Constraints)
    572577        print >>OUTPUT, " {0} {1} {2} \t# nonlinear vars in constraints, objectives, both" \
    573        .format(len(ConNonlinearVarsInt)+len(ConNonlinearVars)+nlv_both, len(ObjNonlinearVarsInt)+len(ObjNonlinearVars)+nlv_both, nlv_both)
    574              
     578        .format(idx_nl_con, idx_nl_obj, idx_nl_both)
     579
    575580        #
    576581        # LINE 6
Note: See TracChangeset for help on using the changeset viewer.