# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003525 with National Technology and
# Engineering Solutions of Sandia, LLC, the U.S. Government retains certain
# rights in this software.
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________
"""
Utilities to support the definition of optimization applications that
can be optimized with the Acro COLIN optimizers.
"""
__all__ = ['OptProblem', 'RealOptProblem', 'MixedIntOptProblem', 'response_enum']
import os
import sys
import enum
from pyomo.opt.blackbox.problem_io import BlackBoxOptProblemIOFactory
from pyomo.opt.blackbox.point import MixedIntVars, RealVars
class response_enum(str, enum.Enum):
FunctionValue='FunctionValue'
FunctionValues='FunctionValues'
Gradient='Gradient'
Hessian='Hessian'
NonlinearConstraintValues='NonlinearConstraintValues'
Jacobian='Jacobian'
# Overloading __str__ is needed to match the behavior of the old
# pyutilib.enum class (removed June 2020). There are spots in the
# code base that expect the string representation for items in the
# enum to not include the class name. New uses of enum shouldn't
# need to do this.
def __str__(self):
return self.value
class OptProblem(object):
"""
A class that defines an application that can be optimized
by a COLIN optimizer via system calls.
"""
def __init__(self):
"""
The constructor. Derived classes should define the response types.
By default, only function evaluations are supported in an OptProblem
instance.
"""
self.response_types = [response_enum.FunctionValue]
def main(self, argv, format='colin'):
"""
The main routine for parsing the command-line and executing
the evaluation.
"""
if len(argv) < 3: #pragma:nocover
print(argv[0 ]+ "