<commit_before>// Copyright 2010-2012 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include <math.h>
#include <stddef.h>
#include "base/hash.h"
#include <limits>
#include <string>
#include <utility>
#include <vector>
#include <float.h>
#include <stdio.h>

#include "base/commandlineflags.h"
#include "base/integral_types.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/stringprintf.h"
#include "base/timer.h"
#include "base/concise_iterator.h"
#include "base/hash.h"
#include "linear_solver/linear_solver.h"

#if defined(USE_SLM)

extern "C" {
  #include "sulumc.h"
}

void ExLogCallbackFunction(enum SlmStream str, const char *strprint, void *handle )
{
  /* Print with printf */
  std::cout <<strprint;
}

#define CheckReturnKey(__ret__)\
{\
  if( (__ret__) != SlmRetOk ) {\
    LOG(FATAL) <<"Error Sulum API call failed : at line "<<__LINE__<<" ret : "<<(__ret__);\
  }\
}

DECLARE_double(solver_timeout_in_seconds);
DECLARE_string(solver_write_model);

namespace operations_research {

// ----- SLM Solver -----

class SLMInterface : public MPSolverInterface {
 public:
  // Constructor that takes a name for the underlying slm solver.
  SLMInterface(MPSolver* const solver, bool mip);
  ~SLMInterface();

  // Sets the optimization direction (min/max).
  virtual void SetOptimizationDirection(bool maximize);

  // ----- Solve -----
  // Solve the problem using the parameter values specified.
  virtual MPSolver::ResultStatus Solve(const MPSolverParameters& param);

  // ----- Model modifications and extraction -----
  // Resets extracted model
  virtual void Reset();<commit_msg>Adding default writing problem and solution file, if the optimizer returns an error code. <commit_after>// Copyright 2010-2012 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

#include <math.h>
#include <stddef.h>
#include "base/hash.h"
#include <limits>
#include <string>
#include <utility>
#include <vector>
#include <float.h>
#include <stdio.h>

#include "base/commandlineflags.h"
#include "base/integral_types.h"
#include "base/logging.h"
#include "base/scoped_ptr.h"
#include "base/stringprintf.h"
#include "base/timer.h"
#include "base/concise_iterator.h"
#include "base/hash.h"
#include "linear_solver/linear_solver.h"

#if defined(USE_SLM)

extern "C" {
  #include "sulumc.h"
}

void ExLogCallbackFunction(enum SlmStream str, const char *strprint, void *handle )
{
  /* Print with printf */
  std::cout <<strprint;
}

#define CheckReturnKey(__ret__)\
{\
  if( (__ret__) != SlmRetOk ) {\
    VLOG(0) <<"Writing problem to  : sulum_error.mps";\
    int wret = SlmWriteProblem(model_,"sulum_error.mps");\
    if( (wret) != SlmRetOk )\
    {\
      VLOG(0) <<"Error writing problem to  : sulum_error.mps : "<<(wret);\
    }\
    VLOG(0) <<"Writing solution to : sulum_error.sol";\
    wret = SlmWriteSolution(model_,"sulum_error.sol");\
    if( (wret) != SlmRetOk )\
    {\
      VLOG(0) <<"Error writing solution to  : sulum_error.sol : "<<(wret);\
    }\
    LOG(FATAL) <<"Error Sulum API call failed : at line "<<__LINE__<<" ret : "<<(__ret__);\
  }\
}

DECLARE_double(solver_timeout_in_seconds);
DECLARE_string(solver_write_model);

namespace operations_research {

// ----- SLM Solver -----

class SLMInterface : public MPSolverInterface {
 public:
  // Constructor that takes a name for the underlying slm solver.
  SLMInterface(MPSolver* const solver, bool mip);
  ~SLMInterface();

  // Sets the optimization direction (min/max).
  virtual void SetOptimizationDirection(bool maximize);

  // ----- Solve -----
  // Solve the problem using the parameter values specified.
  virtual MPSolver::ResultStatus Solve(const MPSolverParameters& param);

  // ----- Model modifications and extraction -----
  // Resets extracted model
  virtual void Reset();
{'fraction_non_alphanumeric': 0.13469133236333403, 'fraction_numerical': 0.005819995842860112, 'mean_word_length': 3.8216432865731464, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3382169', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1491, 'n_words': 476}