1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
Jip J. Dekker f2a1c4e389 Squashed 'software/mza/' content from commit f970a59b17
git-subtree-dir: software/mza
git-subtree-split: f970a59b177c13ca3dd8aaef8cc6681d83b7e813
2021-07-11 16:34:30 +10:00

86 lines
2.3 KiB
C++

/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef __MINIZINC_NL_SOLVER_INSTANCE_HH__
#define __MINIZINC_NL_SOLVER_INSTANCE_HH__
#include <minizinc/ast.hh>
#include <minizinc/flattener.hh>
#include <minizinc/solver.hh>
#include <minizinc/solvers/nl/nl_file.hh>
#ifdef _WIN32
#undef ERROR
#endif
namespace MiniZinc {
class NLSolverOptions : public SolverInstanceBase::Options {
public:
std::string nl_solver;
std::vector<std::string> nl_flags;
std::vector<MZNFZNSolverFlag> nl_solver_flags;
bool do_hexafloat = false;
bool do_keepfile = false;
};
class NLSolverInstance : public SolverInstanceBase {
private:
std::string _fzn_solver;
protected:
Model* _fzn;
Model* _ozn;
NLFile nl_file;
public:
NLSolverInstance(std::ostream& log, SolverInstanceBase::Options* opt);
~NLSolverInstance(void);
Status next(void) override { return SolverInstance::Status::ERROR; }
Status solve(void) override;
void processFlatZinc(void) override;
void resetSolver(void) override;
// TODO: implement
void addConstraint(const std::vector<BytecodeProc>& bs, Constraint* c) override {
assert(false);
};
void addVariable(Variable* var, bool isOutput) override { assert(false); };
Val getSolutionValue(Variable* var) override { return Val(); };
protected:
Expression* getSolutionValue(Id* id);
void analyse(const Item* i);
};
class NL_SolverFactory : public SolverFactory {
protected:
virtual SolverInstanceBase* doCreateSI(std::ostream&, SolverInstanceBase::Options* opt);
public:
NL_SolverFactory(void);
virtual SolverInstanceBase::Options* createOptions(void);
virtual std::string getDescription(SolverInstanceBase::Options* opt = NULL);
virtual std::string getVersion(SolverInstanceBase::Options* opt = NULL);
virtual std::string getId(void);
virtual bool processOption(SolverInstanceBase::Options* opt, int& i,
std::vector<std::string>& argv);
virtual void printHelp(std::ostream& os);
// void setAcceptedFlags(SolverInstanceBase::Options* opt, const std::vector<MZNFZNSolverFlag>&
// flags);
};
} // namespace MiniZinc
#endif