Ejemplo n.º 1
0
 def fix_name(self, mobj, prefix, local_index, hide_names):
     return LP_format.lp_name(
         mobj.name,
         prefix,
         local_index,
         hide_names,
         noncompliant_hook=self._notify_new_non_compliant_name)
Ejemplo n.º 2
0
 def check_lp_name(self, new_name):
     #ModelingObject.check_name(self, new_name)
     if not is_string(new_name) or not new_name:
         self.fatal("Variable name accepts only non-empty strings, {0!r} was passed", new_name)
     elif new_name.find(' ') >= 0:
         self.warning("Variable name contains blank space, var: {0!s}, name: \'{1!s}\'", self, new_name)
     elif not LP_format.is_lp_compliant(new_name):
         self.warning("Candidate variable name is not LP-compliant: '{1}', old_name was: {0} (name will be changed to x<nn>)", self.name, new_name)
Ejemplo n.º 3
0
 def check_lp_name(cls, logger, qualifier, obj, new_name, accept_empty,
                   accept_none):
     from docplex.mp.format import LP_format
     if accept_none and new_name is None:
         pass
     elif not is_string(new_name):
         logger.fatal("{0} name expects a string, {1!r} was passed",
                      qualifier, new_name)
     elif not accept_empty and not new_name:
         logger.fatal(
             "{0} name expects a non-empty string, {0!r} was passed",
             qualifier, new_name)
     elif new_name.find(' ') >= 0:
         logger.warning(
             "{0} name contains blank space, var: {0!s}, name: \'{1!s}\'",
             qualifier, obj, new_name)
     elif not LP_format.is_lp_compliant(new_name):
         logger.warning(
             "{0} name is not LP-compliant: '{2}', old_name was: {1} (name will be changed to x<nn>)",
             qualifier, obj.name, new_name)
Ejemplo n.º 4
0
 def is_lp_compliant(name, do_fix_whitespace=True):
     fixed_name = fix_whitespace(name) if do_fix_whitespace else name
     return LP_format.is_lp_compliant(fixed_name)
Ejemplo n.º 5
0
 def is_lp_compliant(name, fix_whitespace=True):
     fixed_name = LPModelPrinter.fix_whitespace(
         name) if fix_whitespace else name
     return LP_format.is_lp_compliant(fixed_name)