Commit 4d1e6866 authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

updating to include chain_strength option on default param setter



Signed-off-by: Mccaskey, Alex's avatarAlex McCaskey <mccaskeyaj@ornl.gov>
parent 8cf587f8
...@@ -21,8 +21,7 @@ ...@@ -21,8 +21,7 @@
namespace xacc { namespace xacc {
namespace quantum { namespace quantum {
class __attribute__((visibility("default"))) ParameterSetter class ParameterSetter : public Identifiable {
: public Identifiable {
public: public:
virtual std::list<std::shared_ptr<DWQMI>> virtual std::list<std::shared_ptr<DWQMI>>
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
* Alexander J. McCaskey - initial API and implementation * Alexander J. McCaskey - initial API and implementation
*******************************************************************************/ *******************************************************************************/
#include "DefaultParameterSetter.hpp" #include "DefaultParameterSetter.hpp"
#include "XACC.hpp"
namespace xacc { namespace xacc {
namespace quantum { namespace quantum {
...@@ -52,6 +53,11 @@ std::list<std::shared_ptr<DWQMI>> DefaultParameterSetter::setParameters( ...@@ -52,6 +53,11 @@ std::list<std::shared_ptr<DWQMI>> DefaultParameterSetter::setParameters(
} }
} }
double chain_strength = 1.0;
if (xacc::optionExists("chain_strength")) {
chain_strength = std::stod(xacc::getOption("chain_strength"));
}
for (int i = 0; i < nHardwareVerts; i++) { for (int i = 0; i < nHardwareVerts; i++) {
for (int j = 0; j < nHardwareVerts; j++) { for (int j = 0; j < nHardwareVerts; j++) {
if (hardwareGraph->edgeExists(i, j) && i < j && i != j) { if (hardwareGraph->edgeExists(i, j) && i < j && i != j) {
...@@ -77,7 +83,7 @@ std::list<std::shared_ptr<DWQMI>> DefaultParameterSetter::setParameters( ...@@ -77,7 +83,7 @@ std::list<std::shared_ptr<DWQMI>> DefaultParameterSetter::setParameters(
std::fabs(problemGraph->getEdgeWeight(pi, neighbor)); std::fabs(problemGraph->getEdgeWeight(pi, neighbor));
} }
newWeight += std::get<0>(problemGraph->getVertexProperties(pi)); newWeight += std::get<0>(problemGraph->getVertexProperties(pi));
newWeight *= -1.0; newWeight *= -1.0 * chain_strength;
} }
if (std::fabs(newWeight) > 1e-4) { if (std::fabs(newWeight) > 1e-4) {
......
...@@ -14,13 +14,14 @@ ...@@ -14,13 +14,14 @@
#define QUANTUM_AQC_COMPILER_DefaultParameterSetter_HPP_ #define QUANTUM_AQC_COMPILER_DefaultParameterSetter_HPP_
#include "ParameterSetter.hpp" #include "ParameterSetter.hpp"
#include "OptionsProvider.hpp"
namespace xacc { namespace xacc {
namespace quantum { namespace quantum {
/** /**
*/ */
class DefaultParameterSetter : public ParameterSetter { class DefaultParameterSetter : public ParameterSetter, public OptionsProvider {
public: public:
/** /**
...@@ -33,17 +34,29 @@ public: ...@@ -33,17 +34,29 @@ public:
*/ */
virtual ~DefaultParameterSetter() {} virtual ~DefaultParameterSetter() {}
virtual std::list<std::shared_ptr<DWQMI>> std::list<std::shared_ptr<DWQMI>>
setParameters(std::shared_ptr<DWGraph> problemGraph, setParameters(std::shared_ptr<DWGraph> problemGraph,
std::shared_ptr<AcceleratorGraph> hardwareGraph, std::shared_ptr<AcceleratorGraph> hardwareGraph,
Embedding embedding); Embedding embedding) override;
virtual const std::string name() const { return "default"; } const std::string name() const override { return "default"; }
virtual const std::string description() const { const std::string description() const override {
return "This ParameterSetter sets Ising parameters as in the JADE " return "This ParameterSetter sets Ising parameters as in the JADE "
"publication."; "publication.";
} }
std::shared_ptr<options_description> getOptions() override {
auto desc =
std::make_shared<options_description>("Default Parameter Setter Options");
desc->add_options()("chain-strength", value<std::string>(),
"");
return desc;
}
bool handleOptions(variables_map &map) override {
return false;
}
}; };
} // namespace quantum } // namespace quantum
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment