Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding multiple capacity vehicle capability #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Abhishekrana254
Copy link

No description provided.

@@ -134,11 +134,30 @@ template <typename Vector> inline auto makeVectorFromJsNumberArray(v8::Local<v8:

if (!num->IsNumber())
throw std::runtime_error{"Expected array element of types Number"};

//std::cout<<"hello"<<std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The debug prints and the include above have to go before we can merge this

vec.at(atIdx) = Nan::To<std::int32_t>(num).FromJust();
}

return vec;
}

// our function for changing js array into vector of long long int

template <typename Vector> inline auto makeVectorFromJsNumberArray1(v8::Local<v8::Array> array) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this function needed?

@@ -10,33 +10,40 @@
#include <utility>
#include <vector>

struct TSPWorker final : Nan::AsyncWorker {
using Base = Nan::AsyncWorker;
struct TSPWorker final {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this and no longer initialize the base class below? The base class already stores the callback, there should be no need to store it here.


void Execute() override {
void Execute() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please inherit from the NAN AsyncWorker and keep the overrides here and below.

@@ -25,7 +25,7 @@ struct VRPSearchParams {
std::int32_t numVehicles;
std::int32_t depotNode;
std::int32_t timeHorizon;
std::int32_t vehicleCapacity;
std::vector<int64> vehicleCapacity; // type changed to vector
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

if (static_cast<std::int32_t>(array->Length()) != n)
throw std::runtime_error{"Array dimension do not match size"};
// if (static_cast<std::int32_t>(array->Length()) != n)
// throw std::runtime_error{"Array dimension do not match size"};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why commented out?

else if(!costMatrixOk) throw std::runtime_error{"ERROR TYPE 2"};
else if(!durationMatrixOk) throw std::runtime_error{"ERROR TYPE 3"};
else if(!timeWindowsVectorOk) throw std::runtime_error{"ERROR TYPE 4"};
else if(!demandMatrixOk) throw std::runtime_error{"ERROR TYPE 5"};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here?

@@ -170,7 +177,7 @@ VRPSearchParams::VRPSearchParams(const Nan::FunctionCallbackInfo<v8::Value>& inf
auto numVehiclesOk = !maybeNumVehicles.IsEmpty() && maybeNumVehicles.ToLocalChecked()->IsNumber();
auto depotNodeOk = !maybeDepotNode.IsEmpty() && maybeDepotNode.ToLocalChecked()->IsNumber();
auto timeHorizonOk = !maybeTimeHorizon.IsEmpty() && maybeTimeHorizon.ToLocalChecked()->IsNumber();
auto vehicleCapacityOk = !maybeVehicleCapacity.IsEmpty() && maybeVehicleCapacity.ToLocalChecked()->IsNumber();
auto vehicleCapacityOk = !maybeVehicleCapacity.IsEmpty() && maybeVehicleCapacity.ToLocalChecked()->IsArray(); // IsNumber() changed to IsArray()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

@@ -192,7 +199,9 @@ VRPSearchParams::VRPSearchParams(const Nan::FunctionCallbackInfo<v8::Value>& inf
numVehicles = Nan::To<std::int32_t>(maybeNumVehicles.ToLocalChecked()).FromJust();
depotNode = Nan::To<std::int32_t>(maybeDepotNode.ToLocalChecked()).FromJust();
timeHorizon = Nan::To<std::int32_t>(maybeTimeHorizon.ToLocalChecked()).FromJust();
vehicleCapacity = Nan::To<std::int32_t>(maybeVehicleCapacity.ToLocalChecked()).FromJust();
//vehicleCapacity = Nan::To<std::int32_t>(maybeVehicleCapacity.ToLocalChecked()).FromJust();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why commented out?

@@ -32,7 +32,7 @@ struct VRPWorker final : Nan::AsyncWorker {
std::int32_t numVehicles_, //
std::int32_t vehicleDepot_, //
std::int32_t timeHorizon_, //
std::int32_t vehicleCapacity_, //
std::vector<int64> vehicleCapacity_, // type changed to vector int64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change from int32s to int64s?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was because the AddDimensionWithVehicleCapacity() takes long long integer array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants