smremde / node-lp_solve Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Any idea on why set_timeout isn't working? Things I tried:
int
instead of a long
sectimeout
was 5 secondsNothing seemed to work.
I am able to set my column constraint to an int but I want to define them as binary instead. I followed some of the source to the addColumn function in LinearProgram.js which will call setColumnInteger. I saw that will then call set_int -- is there a way to call set_bin? Or perhaps there is another way for me to set upper and lower bounds so that my variable can be 0 <= x1 <= 1
I upgrade my node version from 0.8.17 to 4.1 and now lo_solve stopped working.
I tried to do fresh npm install but still failed.
Do I suppose to do any other step?
I don't know if this is still being maintained but I am currently on node v10.2.1 and installing this package with v0.2.13 fails with the following error:
/home/maks/.node-gyp/10.2.1/include/node/v8config.h:318:3: note: in definition of macro ‘V8_DEPRECATED’
318 | declarator attribute((deprecated(message)))
| ^~~~~~~~~~
../lp_solve.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE LinearProgram::print_debugdump(Nan::NAN_METHOD_ARGS_TYPE)’:
../lp_solve.cc:2206:40: warning: ‘v8::String::Utf8Value::Utf8Value(v8::Localv8::Value)’ is deprecated: Use Isolate version [-Wdeprecated-declarations]
2206 | String::Utf8Value str_filename(info[0]);
| ^
In file included from /home/maks/.node-gyp/10.2.1/include/node/v8.h:26,
from /home/maks/.node-gyp/10.2.1/include/node/node.h:63,
from ../lp_solve.cc:1:
/home/maks/.node-gyp/10.2.1/include/node/v8.h:2822:28: note: declared here
2822 | explicit Utf8Value(Localv8::Value obj));
| ^~~~~~~~~
/home/maks/.node-gyp/10.2.1/include/node/v8config.h:318:3: note: in definition of macro ‘V8_DEPRECATED’
318 | declarator attribute((deprecated(message)))
| ^~~~~~~~~~
../lp_solve.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE LinearProgram::get_nameindex(Nan::NAN_METHOD_ARGS_TYPE)’:
../lp_solve.cc:2597:39: warning: ‘v8::String::Utf8Value::Utf8Value(v8::Localv8::Value)’ is deprecated: Use Isolate version [-Wdeprecated-declarations]
2597 | String::Utf8Value str_varname(info[0]);
| ^
In file included from /home/maks/.node-gyp/10.2.1/include/node/v8.h:26,
from /home/maks/.node-gyp/10.2.1/include/node/node.h:63,
from ../lp_solve.cc:1:
/home/maks/.node-gyp/10.2.1/include/node/v8.h:2822:28: note: declared here
2822 | explicit Utf8Value(Localv8::Value obj));
| ^~~~~~~~~
/home/maks/.node-gyp/10.2.1/include/node/v8config.h:318:3: note: in definition of macro ‘V8_DEPRECATED’
318 | declarator attribute((deprecated(message)))
| ^~~~~~~~~~
In file included from /home/maks/.node-gyp/10.2.1/include/node/node.h:63,
from ../lp_solve.cc:1:
/home/maks/.node-gyp/10.2.1/include/node/v8.h: In instantiation of ‘void v8::PersistentBase::SetWeak(P*, typename v8::WeakCallbackInfo::Callback, v8::WeakCallbackType) [with P = node::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo
::Callback = void ()(const v8::WeakCallbackInfonode::ObjectWrap&)]’:
/home/maks/.node-gyp/10.2.1/include/node/node_object_wrap.h:85:78: required from here
/home/maks/.node-gyp/10.2.1/include/node/v8.h:9238:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfonode::ObjectWrap::Callback’ {aka ‘void ()(const v8::WeakCallbackInfonode::ObjectWrap&)’} to ‘Callback’ {aka ‘void ()(const v8::WeakCallbackInfo&)’} [-Wcast-function-type]
9238 | reinterpret_cast(callback), type);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/maks/.node-gyp/10.2.1/include/node/v8.h: In instantiation of ‘void v8::PersistentBase::SetWeak(P, typename v8::WeakCallbackInfo::Callback, v8::WeakCallbackType) [with P = Nan::ObjectWrap; T = v8::Object; typename v8::WeakCallbackInfo
::Callback = void ()(const v8::WeakCallbackInfoNan::ObjectWrap&)]’:
../node_modules/nan/nan_object_wrap.h:66:61: required from here
/home/maks/.node-gyp/10.2.1/include/node/v8.h:9238:16: warning: cast between incompatible function types from ‘v8::WeakCallbackInfoNan::ObjectWrap::Callback’ {aka ‘void ()(const v8::WeakCallbackInfoNan::ObjectWrap&)’} to ‘Callback’ {aka ‘void (*)(const v8::WeakCallbackInfo&)’} [-Wcast-function-type]
make: *** [lp_solve.target.mk:106: Release/obj.target/lp_solve/lp_solve.o] Error 1
make: Leaving directory '/mnt/data/coding/mw/node_modules/lp_solve/build'
gyp ERR! build error
gyp ERR! stack Error:make
failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:237:12)
gyp ERR! System Linux 5.1.16-arch1-1-ARCH
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /mnt/data/coding/mw/node_modules/lp_solve
gyp ERR! node -v v10.2.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN rollback Rolling back [email protected] failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/mnt/data/coding/mw/node_modules/lp_solve/node_modules/bindings'
npm WARN rollback Rolling back [email protected] failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/mnt/data/coding/mw/node_modules/lp_solve/node_modules/nan'
npm WARN rollback Rolling back [email protected] failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/mnt/data/coding/mw/node_modules/lp_solve/node_modules/bindings'
npm WARN [email protected] No description
npm WARN [email protected] No repository field.npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install:node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:
npm ERR! /home/maks/.npm/_logs/2019-07-11T06_42_38_936Z-debug.log
Tried to install on v 0.12 and v4.0.0, from other packages, looks like this probably goes back to v0.11.
In file included from ../lp_solve.cc:2:
../node_modules/nan/nan.h:318:13: error: no member named 'New' in 'v8::String'
return _NAN_ERROR(v8::Exception::Error, errmsg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:298:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
~~~~~~~~~~~~^
../node_modules/nan/nan.h:322:5: error: no member named 'ThrowException' in namespace 'v8'
_NAN_THROW_ERROR(v8::Exception::Error, errmsg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:303:11: note: expanded from macro '_NAN_THROW_ERROR'
v8::ThrowException(_NAN_ERROR(fun, errmsg)); \
~~~~^
../node_modules/nan/nan.h:322:5: error: no member named 'New' in 'v8::String'
_NAN_THROW_ERROR(v8::Exception::Error, errmsg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:303:26: note: expanded from macro '_NAN_THROW_ERROR'
v8::ThrowException(_NAN_ERROR(fun, errmsg)); \
^~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:298:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
~~~~~~~~~~~~^
../node_modules/nan/nan.h:327:9: error: no type named 'ThrowException' in namespace 'v8'
v8::ThrowException(error);
~~~~^
../node_modules/nan/nan.h:334:65: error: no member named 'New' in 'v8::String'
v8::Local<v8::Value> err = v8::Exception::Error(v8::String::New(msg));
~~~~~~~~~~~~^
../node_modules/nan/nan.h:336:26: error: no member named 'New' in 'v8::String'
obj->Set(v8::String::New("code"), v8::Int32::New(errorNumber));
~~~~~~~~~~~~^
../node_modules/nan/nan.h:348:12: error: no member named 'New' in 'v8::String'
return _NAN_ERROR(v8::Exception::TypeError, errmsg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:298:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
~~~~~~~~~~~~^
../node_modules/nan/nan.h:352:5: error: no member named 'ThrowException' in namespace 'v8'
_NAN_THROW_ERROR(v8::Exception::TypeError, errmsg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:303:11: note: expanded from macro '_NAN_THROW_ERROR'
v8::ThrowException(_NAN_ERROR(fun, errmsg)); \
~~~~^
../node_modules/nan/nan.h:352:5: error: no member named 'New' in 'v8::String'
_NAN_THROW_ERROR(v8::Exception::TypeError, errmsg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:303:26: note: expanded from macro '_NAN_THROW_ERROR'
v8::ThrowException(_NAN_ERROR(fun, errmsg)); \
^~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:298:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
~~~~~~~~~~~~^
../node_modules/nan/nan.h:356:12: error: no member named 'New' in 'v8::String'
return _NAN_ERROR(v8::Exception::RangeError, errmsg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:298:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
~~~~~~~~~~~~^
../node_modules/nan/nan.h:360:5: error: no member named 'ThrowException' in namespace 'v8'
_NAN_THROW_ERROR(v8::Exception::RangeError, errmsg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:303:11: note: expanded from macro '_NAN_THROW_ERROR'
v8::ThrowException(_NAN_ERROR(fun, errmsg)); \
~~~~^
../node_modules/nan/nan.h:360:5: error: no member named 'New' in 'v8::String'
_NAN_THROW_ERROR(v8::Exception::RangeError, errmsg);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:303:26: note: expanded from macro '_NAN_THROW_ERROR'
v8::ThrowException(_NAN_ERROR(fun, errmsg)); \
^~~~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:298:50: note: expanded from macro '_NAN_ERROR'
# define _NAN_ERROR(fun, errmsg) fun(v8::String::New(errmsg))
~~~~~~~~~~~~^
../node_modules/nan/nan.h:379:13: error: no member named 'smalloc' in namespace 'node'
, node::smalloc::FreeCallback callback
~~~~~~^
../node_modules/nan/nan.h:119:71: note: expanded from macro 'NAN_INLINE'
# define NAN_INLINE(declarator) inline __attribute__((always_inline)) declarator
^
../node_modules/nan/nan.h:389:12: error: no matching function for call to 'New'
return node::Buffer::New(data, size);
^~~~~~~~~~~~~~~~~
/Users/facil/.node-gyp/4.0.0/include/node/node_buffer.h:28:40: note: candidate function not viable: no known conversion from 'char *' to 'v8::Isolate *' for 1st argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
^
/Users/facil/.node-gyp/4.0.0/include/node/node_buffer.h:31:40: note: candidate function not viable: no known conversion from 'char *' to 'v8::Isolate *' for 1st argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
/Users/facil/.node-gyp/4.0.0/include/node/node_buffer.h:36:40: note: candidate function not viable: requires 5 arguments, but 2 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
/Users/facil/.node-gyp/4.0.0/include/node/node_buffer.h:43:40: note: candidate function not viable: requires 3 arguments, but 2 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
In file included from ../lp_solve.cc:2:
../node_modules/nan/nan.h:393:12: error: no matching function for call to 'New'
return node::Buffer::New(size);
^~~~~~~~~~~~~~~~~
/Users/facil/.node-gyp/4.0.0/include/node/node_buffer.h:28:40: note: candidate function not viable: requires 2 arguments, but 1 was provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
^
/Users/facil/.node-gyp/4.0.0/include/node/node_buffer.h:31:40: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
/Users/facil/.node-gyp/4.0.0/include/node/node_buffer.h:36:40: note: candidate function not viable: requires 5 arguments, but 1 was provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
/Users/facil/.node-gyp/4.0.0/include/node/node_buffer.h:43:40: note: candidate function not viable: requires 3 arguments, but 1 was provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
^
In file included from ../lp_solve.cc:2:
../node_modules/nan/nan.h:400:26: error: no member named 'Use' in namespace 'node::Buffer'
return node::Buffer::Use(data, size);
~~~~~~~~~~~~~~^
../node_modules/nan/nan.h:668:49: error: too few arguments to function call, single argument 'isolate' was not specified
v8::Local<v8::Object> obj = v8::Object::New();
~~~~~~~~~~~~~~~ ^
/Users/facil/.node-gyp/4.0.0/include/node/v8.h:2933:3: note: 'New' declared here
static Local<Object> New(Isolate* isolate);
^
In file included from ../lp_solve.cc:2:
../node_modules/nan/nan.h:669:14: error: no member named 'NewSymbol' in 'v8::String'; did you mean 'IsSymbol'?
obj->Set(NanSymbol("callback"), fn);
^~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:159:38: note: expanded from macro 'NanSymbol'
#define NanSymbol(value) v8::String::NewSymbol(value)
~~~~~~~~~~~~^
/Users/facil/.node-gyp/4.0.0/include/node/v8.h:1726:8: note: 'IsSymbol' declared here
bool IsSymbol() const;
^
In file included from ../lp_solve.cc:2:
../node_modules/nan/nan.h:669:14: error: call to non-static member function without an object argument
obj->Set(NanSymbol("callback"), fn);
^~~~~~~~~~~~~~~~~~~~~
../node_modules/nan/nan.h:159:38: note: expanded from macro 'NanSymbol'
#define NanSymbol(value) v8::String::NewSymbol(value)
~~~~~~~~~~~~^~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/lp_solve/lp_solve.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/facil/Code/SBRP/node_modules/lp_solve
gyp ERR! node -v v4.0.0
gyp ERR! node-gyp -v v3.0.1
gyp ERR! not ok
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "lp_solve" "--save"
npm ERR! node v4.0.0
npm ERR! npm v2.14.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the lp_solve package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls lp_solve
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/facil/Code/SBRP/npm-debug.log
should be included as a dependency in package.json or removed from project
With small numbers of (1<count*batch<~20) the test fails
With large number (count * batch > 50) it works fine
With 1 (count * batch = 1) it works fine
For me, 1< count*batch<9 fails.
The call actually returns an error even though lp_solve solve return ok.
Hi, I am tying to do Data envelopment analysis(DEA) with node-lp_solve to solve linear programming problems. So far, I can get the correct solution and objectvalue, but I can't get duals variables (because DEA need them). So is there any possible I can get duals variables by some function?
For those who are using TypeScript, I've created a declaration file for "lp_solve".
This file can be merged into this repository (until then you can copy and paste it into your own project)
declare module "lp_solve" {
type ContraintTypes = "LE" | "EQ" | "GE";
type SolveResult =
"UNKNOWNERROR" |
"DATAIGNORED" |
"NOBFP" |
"NOMEMORY" |
"NOTRUN" |
"OPTIMAL" |
"SUBOPTIMAL" |
"INFEASIBLE" |
"UNBOUNDED" |
"DEGENERATE" |
"NUMFAILURE" |
"USERABORT" |
"TIMEOUT" |
"RUNNING" |
"PRESOLVED";
class LinearProgram {
constructor();
addColumn(name?: string, isInteger?: boolean, isBinary?: boolean): string;
setObjective(row: Row, minimize?: boolean): void;
addConstraint(row: Row, constraint: ContraintTypes, constant: number, name?: string): void;
dumpProgram(): string;
solve(): Solution;
/**
* sets the amount of information to be reported by solve
*/
setVerbose(verb: number): { verbosity: number; errorMsg?: string };
getObjectiveValue(): number;
getSolutionVariables(): number[] | null;
get(variable: string): number | undefined | null;
calculate(row: Row): number;
Columns: { [index: string]: number };
modelNames: boolean;
localConstraints: boolean;
lprec: LP;
}
interface LP {
get_Nrows(): number;
del_constraint(index: number): boolean;
}
/**
* class to hold factor:attribute pairs
*/
class Row {
constructor(clone?: Row);
/**
* adds a row or a variable:factor to this row
*/
Add(b: string, c?: number): Row;
/**
* subtract a row or variable:factor to this row
*/
Subtract(b: string, c?: number): Row;
/**
* multiplies all the factors by a fixed value
*/
Multiply(v: number): Row;
/**
* converts an object of vairable:factor to an equation for LP Solve
*/
ToText(): string;
raw: { [index: string]: number };
}
interface Solution {
code: number;
description: SolveResult;
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.