Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • ffd0861
  • /
  • Solver.h
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:e9239aa50f818be94b9f4ef2e32274b64a5244c6
directory badge
swh:1:dir:ffd086171f1b0b5cf0c80beb89acae77e3b32bb5

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Solver.h
#ifndef SOLVER_H
#define SOLVER_H


#include <iostream>
#include <vector>
#include <armadillo>
#include <nlopt.hpp>


using namespace std;

enum ConstraintMethod{
    CM_EQUAL,
    CM_LESS,
    CM_GREATER,
    CM_RANGE
};


struct triple{
    int i;
    int j;
    double val;
    triple(int i,int j,double val):i(i),j(j),val(val){}
};

struct LinearVec{

    vector<int>ts;
    vector<double>ws;
    double a;
    double b;
    int label;
    ConstraintMethod mt;


    LinearVec(){}
    LinearVec(int label):label(label){}
    void clear();
    void push_back(int t, double w);
    void set_label(int label);
    void set_ab(double a, double b);
};

struct QuadraticVec{

    vector<triple>ts;
    double b;
    ConstraintMethod mt;

    QuadraticVec(){}
    QuadraticVec(vector<triple>&ts, double b):ts(ts),b(b){}

    void push_back(int i,int j,double val);
    void set_b(double b);
    void clear();
};

struct NLOptConstraint{
    nlopt::vfunc constraintfunc;
    ConstraintMethod mt;
    void *data;

};


struct Solution_Struct{
    int Statue;
    double init_energy;
    double energy;
    double time;
    vector<double>solveval;
    arma::vec solvec_arma;

    Solution_Struct():init_energy(-1),energy(-1){}
    void init(int n);
};

class Solver{


public:

//    GRBEnv objenv;
//    GRBModel objmodel;

//    vector<GRBVar>c_vars;

public:
//    Solver():objenv(GRBEnv()),objmodel(GRBModel(objenv)){

//        objmodel.getEnv().set(GRB_IntParam_OutputFlag, 0);

//    }

    Solver(){}


public:


//    static int solveQuadraticProgramming(vector<triple> &M, vector<triple> &Ab,int n, vector<double>&solveval);

//    static int solveQuadraticProgramming(vector<triple> &M, vector<LinearVec> &Ab,int n, vector<double>&solveval);
//    static int solveQuadraticProgramming(arma::mat &M, vector<LinearVec> &Ab,int n, Solution_Struct &sol);


//    static int solveLinearLS(vector<triple> &M, vector<double> &b, int n, vector<double>&solveval);

//    static int solveQCQP(arma::mat &M, vector<LinearVec> &Ab, vector<QuadraticVec> &Cb, int n, Solution_Struct &sol);

    //int solveQP_multiupdata_main(Solution_Struct &sol, vector<LinearVec> &Ab, int n, bool suppressinfo = true);
    //int solveQP_multiupdata_init(arma::mat &M, int n);



    static int nloptwrapper(vector<double>&lowerbound,
                   vector<double>&upperbound,
                   nlopt::vfunc optfunc,
                   void *funcPara,
                   vector<NLOptConstraint>&nl_constraints,
                   double tor,
                   int maxIter,
                   Solution_Struct &sol
                   );

    static int nloptwrapper(vector<double>&lowerbound,
                   vector<double>&upperbound,
                   nlopt::vfunc optfunc,
                   void *funcPara,
                   double tor,
                   int maxIter,
                   Solution_Struct &sol
                   );

};




















#endif // SOLVER_H

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API