Changeset 2218


Ignore:
Timestamp:
Feb 1, 2010 12:11:59 AM (10 years ago)
Author:
wehart
Message:

Reworking the symbol_map generated for the NL file.

Fixing the use of this within PyomoModel? when loading data.

Adding logic to specify the 'solver' option when an optimization interface
is specified (e.g. asl:cplexamp).

Location:
coopr.pyomo/trunk/coopr/pyomo
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/base/PyomoModel.py

    r2201 r2218  
    384384             # translate the name first if there is a variable map associated with the input solution.
    385385             if symbol_map is not None:
    386                  name = symbol_map[name]
     386                name = symbol_map[name]
    387387             if name not in self._name_varmap:
    388388                names=""
     
    393393                raise TypeError, "Variable '"+name+"' in model '"+self.name+"' is currently fixed - new value is not expected in solution"
    394394
     395             print "HERE",name
    395396             var_value = self._name_varmap[name]
    396397             for _key in entry.keys():
     
    417418             if name[0:2] == 'c_':
    418419                _name = name[4:-1]
     420             else:
     421                _name = name
    419422
    420423             if _name not in self._name_conmap:
  • coopr.pyomo/trunk/coopr/pyomo/io/ampl.py

    r2217 r2218  
    252252                                    self._get_bound(C[ndx].lower)-offset,\
    253253                                    self._get_bound(C[ndx].upper)-offset,
    254                 print >>OUTPUT, " # c"+ str(nc)+"  "+str(key) + "[" + str(ndx) + "]"
    255                 symbol_map["c" + str(nc)] = str(key) + "[" + str(ndx) + "]"
     254                print >>OUTPUT, " # c"+ str(nc)+"  "+C[ndx].label #str(key) + "[" + str(ndx) + "]"
     255                symbol_map["c" + str(nc)] = C[ndx].label #str(key) + "[" + str(ndx) + "]"
    256256                nc += 1
    257257        #
     
    259259        #
    260260        print >>OUTPUT, "b"
    261         nv=0
    262261        for ndx in Vlist:
    263262            vv = Var[ndx]
     
    267266            if isinstance(var.domain, BooleanSet):
    268267                print >>OUTPUT, "0 0 1",
    269                 print >>OUTPUT, " # v"+str(nv)+"  "+vv.label
    270                 nv += 1
     268                print >>OUTPUT, " # v"+str(var_id[ndx])+"  "+vv.label
     269                symbol_map["v"+str(var_id[ndx])] = vv.label
    271270                continue
    272271            L = vv.lb
     
    286285            else:
    287286                print >>OUTPUT, "3",
    288             print >>OUTPUT, " # v"+str(nv)+"  "+vv.label
    289             symbol_map["v"+str(nv)] = vv.label
    290 
    291             nv += 1
     287            print >>OUTPUT, " # v"+str(var_id[ndx])+"  "+vv.label
     288            symbol_map["v"+str(var_id[ndx])] = vv.label
    292289        #
    293290        # "k" lines
  • coopr.pyomo/trunk/coopr/pyomo/scripting/util.py

    r2213 r2218  
    224224    # Create Solver and Perform Optimization
    225225    #
    226     opt = SolverFactory( options.solver )
     226    solver = options.solver
     227    subsolver=None
     228    if not solver is None and ':' in solver:
     229        solver, subsolver = solver.split(':')
     230    opt = SolverFactory( solver )
    227231    if opt is None:
    228        raise ValueError, "Problem constructing solver `"+str(options.solver)+"'"
     232       raise ValueError, "Problem constructing solver `"+str(solver)+"'"
    229233    opt.keepFiles=options.keepfiles or options.log
    230234    if options.timelimit == 0:
     
    232236    if options.solver_mipgap is not None:
    233237       opt.mipgap = options.solver_mipgap
     238    if not subsolver is None:
     239        subsolver=' solver='+subsolver
     240    else:
     241        subsolver=''
     242    opt.set_options(" ".join(options.solver_options)+subsolver)
     243    #
    234244    solver_mngr = SolverManagerFactory( options.smanager_type )
    235245    if solver_mngr is None:
    236246       raise ValueError, "Problem constructing solver manager `"+str(options.smanager_type)+"'"
    237     results = solver_mngr.solve(instance, opt=opt, tee=options.tee, timelimit=options.timelimit, options=" ".join(options.solver_options))
     247    results = solver_mngr.solve(instance, opt=opt, tee=options.tee, timelimit=options.timelimit)
    238248    if results == None:
    239249            raise ValueError, "opt.solve returned None"
Note: See TracChangeset for help on using the changeset viewer.