Not running example
EricSmekens opened this issue · 0 comments
EricSmekens commented
I created a Node.js project, and installed Algorithmbox with npm.
//base algorithm definition of hill climbing
var IIA = require('algorithmbox').IIA;
var defineClass = require('algorithmbox').defineClass;
//extend the framework-provided IIA definition
//DEFINECLASS is UNDEFINED
var MyIIA = defineClass({
name : "MyIIA",
extend : IIA,
methods : {
//given a candidate solution, return a set of neighborhood
//solutions that can be reached by 1-point mutation
'neighbors' : function neighbors(candidate) {
}
}
});
//
var TSP = require('algorithmbox').TSP;
//load tsp instance from file
var raw = fs.readFileSync('tsplib/bayg29.xml');
//parse data and create a TSP instance
var instance = new TSP(TSP.parseData(raw));
//create a IIA algorithm with predefined terminate condition
var algs = new MyIIA(instance, {
'terminate_ls_steps' : 1000 //stop if maximum search steps reached
});
//run the algorithm and monitor progress
algs.run(function(step){
console.log("step %d. best found solution: [%s]", step, algs.best_sol);
if(algs.lo_trap)
console.log("trapped"); //algorithm trapped in local optima
});
But defineClass is undefined. It's not in the exports of the main index.js of the module.