Exemple #1
0
int maxFlow(struct node * graph[], int from ,int to, int nV)
{
	struct node * resgraph[nV];
	struct node * temp;
	int i, j, temp_weight;
	int parent[nV];
	int max_flow = 0, path_flow;
	for(i = 0; i < nV; i++)
	{
		resgraph[i] = NULL;
	}
	
	for(i = 0; i < nV; i++)
	{
		temp = graph[i];
		while(temp != NULL)
		{
			addEdge(&resgraph[i], temp->toNode, temp->weight);
			temp = temp->next;
		}
	}
	
	while(breadthFirst(resgraph, from, to, nV, parent))
	{
		j = to;
		path_flow = MAX;
		while(j != from)
		{
			i = parent[j];
			temp_weight = weight(resgraph, i ,j, nV);
			j = i;
			if(path_flow < temp_weight)
				path_flow = path_flow;
			else
				path_flow = temp_weight;
		}
		j = to;
		while(j != from)
		{
			i = parent[j];
			updateWeight(resgraph, i, j, -path_flow);
			updateWeight(resgraph, j, i, path_flow);
			j = i;
		}
		max_flow += path_flow;
	}
	return max_flow;
}
Exemple #2
0
void Plant::update() {
    if (startNow())
        weight = initWeight;
    updateCrownZoneArea();
    updateLightInterception();
    updateWeight();
}
Exemple #3
0
void MainWindow::createButtonLayout() {
  buttonLayout=new QHBoxLayout;
  buttonupdate = createButton(tr("Update Weight"), this, SLOT(updateWeight()));
  buttonexit = createButton(tr("Quit"), this, SLOT(close()));
  buttonLayout->addStretch();
  buttonLayout->addWidget(buttonupdate);
  buttonLayout->addWidget(buttonexit);
  
}
Exemple #4
0
void User::setWeight(double weight) {

    if(myWeight != weight) {
        myWeight = weight;
        updateWeight(weight);
        calculateBMI();
        calculateBMR();
        emit weightChanged();
    }
}
Exemple #5
0
void InventoryWindow::event(const std::string &channel, const Mana::Event &event)
{
    if (event.getName() == "UpdateAttribute")
    {
        int id = event.getInt("id");
        if (id == TOTAL_WEIGHT ||
            id == MAX_WEIGHT)
        {
            updateWeight();
        }
    }
}
Exemple #6
0
int
Strategy1::bestMove( const std::vector<int> & moves,
                     int n_moves, int & from, int & to,
                     bool do_print ) 
{
  // if ( do_print ) printf("BestMove() scores ");
  double score = SCORE_MIN;
  int f0 = -1, t0 = -1;
  int f, t;
  int ret = -1;
  Weight wei_from;
  Weight wei_to;
  updateWeight( wei_to, board );

  for ( int k=0; k<n_moves; ++k) {
    if ( do_print ) printf("move [%d] ", moves[k] );
    double s = movingHomeScore( moves[k], f, wei_from );
    if ( do_print ) printf("Home %6.2f from %d ", s, f );
    if ( s > score ) {
      score = s;
      f0 = f;
      t0 = POS_HOME;
      ret = moves[k];
    }
    s = movingBackScore( moves[k], f, t, wei_from, wei_to );
    if ( do_print ) printf("Back %6.2f from %d to %d ", s, f, t );
    if ( s > score ) {
      score = s;
      f0 = f;
      t0 = t;
      ret = moves[k];
    }
    s = movingForScore( moves[k], f, t, wei_from, wei_to );
    if ( do_print ) printf("For %6.2f from %d to %d ", s, f, t );
    if ( s > score ) {
      score = s;
      f0 = f;
      t0 = t;
      ret = moves[k];
    }
  }
  if ( do_print ) printf(" Best from %d to %d ret %d \n", f0, t0, ret);
  from = f0;
  to   = t0;
  return ret;
}
Exemple #7
0
void AdaBoost::trainRound() {
    calcWeightSum();
    
    DecisionStump bestClassifier;
    for (int featureIndex = 0; featureIndex < featureTotal_; ++featureIndex) {
        DecisionStump optimalClassifier = learnOptimalClassifier(featureIndex);
        if (optimalClassifier.featureIndex() < 0) continue;
        
        if (bestClassifier.error() < 0 || optimalClassifier.error() < bestClassifier.error()) {
            bestClassifier = optimalClassifier;
        }
    }
    
    updateWeight(bestClassifier);
    
    weakClassifiers_.push_back(bestClassifier);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Find the second point to be updated
bool searchPoint(unsigned int& I1, unsigned int I2,double* weights,double* Q,double* D,unsigned int N, double& wI1_old)
{
  double dW=0, dWabs=0, W1, W2;
  unsigned int i,j;
  I1 = I2;  // default is, do nothing
  W2 = 0; 
  for (j=0;j<N;j++)  W2 += weights[j] * Q[N*j + I2];
  W2 -= D[I2];
  for (i=0; i<N; i++) {
    if (weights[i] <= weightTolerance) continue;
    W1 = 0;
    for (j=0;j<N;j++)  W1 += weights[j] * Q[i + N*j];
    W1 -= D[i];
    if (fabs(W1-W2) > dWabs) {
      dWabs = fabs(W1-W2); dW = W1-W2; I1 = i;
    }
  }
  wI1_old = weights[I1];
  return updateWeight(I1,I2,weights,dW,Q,N);
}
//! main function for Conditioning experiment
int main() {

  // set up random number generator:
	gsl_rng_env_setup();
	r = gsl_rng_alloc(gsl_rng_default);
	gsl_rng_set(r, RANDOM_SEED);

	// initialise the specifice parameters for this simulation.
	initDerivedParams();
	
	//char filename[1024];
	//sprintf(filename, "data/conditioning_%d_%4f_%d.dat", TRAININGCYCLES, ETA, TAU_ALPHA);
	FILE *F = fopen(FILENAME, "w+b"); //! output file name
	
	gsl_vector *psp = gsl_vector_alloc(NPRE); //! to hold PSPs
	gsl_vector *pspS = gsl_vector_alloc(NPRE); //! to hold (filtered?) PSPs
	gsl_vector *sue = gsl_vector_alloc(NPRE); //! "positive" part of PSP fur integration
	gsl_vector *sui = gsl_vector_alloc(NPRE); //! "negative" part of PSP fur integration
	gsl_vector *pspTilde = gsl_vector_alloc(NPRE); //! low pass (2nd) filtered PSS
	gsl_vector *wB  = gsl_vector_alloc(NPRE); //! weights of connections to Bacon neuron
	gsl_vector *wW  = gsl_vector_alloc(NPRE); //! weights of connections to Water neuron
	gsl_vector *wR  = gsl_vector_alloc(NPRE);  //! weights of connections to Reward neuron
	gsl_vector *ou  = gsl_vector_alloc(NPRE); //! xxxx
	gsl_vector *oum  = gsl_vector_alloc(NPRE); //! xxx
	gsl_vector *pres  = gsl_vector_alloc(NPRE); //! xxx

	//! short-hand pointer to the datastructures above.
	double *pspP = gsl_vector_ptr(psp,0);
	double *pspSP = gsl_vector_ptr(pspS,0);
	double *sueP = gsl_vector_ptr(sue,0);
	double *suiP = gsl_vector_ptr(sui,0);
	double *pspTildeP = gsl_vector_ptr(pspTilde,0);
	double *wBP = gsl_vector_ptr(wB,0);
	double *wWP = gsl_vector_ptr(wW,0);
	double *wRP = gsl_vector_ptr(wR,0);
	double *ouP = gsl_vector_ptr(ou,0);
	double *oumP = gsl_vector_ptr(oum,0);
	double *presP = gsl_vector_ptr(pres,0);

	// initialise data structures:
	for(int i=0; i<NPRE; i++) {
	  *(pspP+i) = 0;
		*(sueP+i) = 0;
		*(suiP+i) = 0;
		// random connections to B, W, and R neurons
		*(wBP+i) = gsl_ran_gaussian(r, .04) + .07; 
		*(wWP+i) = gsl_ran_gaussian(r, .04) + .07;
		*(wRP+i) = gsl_ran_gaussian(r, .04) + .07;
	}
	
	/*! Bacon neuron:
	  - uB soma potential
	  - uVB potential from dendrited alone
	  - rU rate from some
	  - rVB rate from dentritic input alone
	  and then the same for W,R neurons
	*/
	double uB = 0, uVB = 0, rUB = 0, rVB = 0;
	double uW = 0, uVW = 0, rUW = 0, rVW = 0;
	double uR = 0, uVR = 0, rUR = 0, rVR = 0;
	
	//! we only recorded activites of this many pres
	int nOfRecordedPre = 50;
	//! this describes the length of the network state we store
	int stateLength = 4 * nOfRecordedPre + 12;
	//! the states consistes of u, uV, rU, rV of all recorded pres and of B,R,W neurons.
	double *state[stateLength];
	for(int i = 0; i < nOfRecordedPre; i++) {
	  *(state + 0*nOfRecordedPre + i) = wBP + i; // points to weight vector of connection to B etc
	  *(state + 1*nOfRecordedPre + i) = wWP + i; 
	  *(state + 2*nOfRecordedPre + i) = wRP + i;
	  *(state + 3*nOfRecordedPre + i) = presP + i; // points to presP values
	} 
	*(state + 4*nOfRecordedPre) = &uB; // points to potential u of B etc
	*(state + 4*nOfRecordedPre+1) = &uVB;
	*(state + 4*nOfRecordedPre+2) = &rUB;
	*(state + 4*nOfRecordedPre+3) = &rVB;
	*(state + 4*nOfRecordedPre+4) = &uW;
	*(state + 4*nOfRecordedPre+5) = &uVW;
	*(state + 4*nOfRecordedPre+6) = &rUW;
	*(state + 4*nOfRecordedPre+7) = &rVW;
	*(state + 4*nOfRecordedPre+8) = &uR;
	*(state + 4*nOfRecordedPre+9) = &uVR;
	*(state + 4*nOfRecordedPre+10) = &rUR;
	*(state + 4*nOfRecordedPre+11) = &rVR;
	
	// pointers to input currents  xxx to do with B,W,R
	//! \todo why initialised this way?
	double *IB, *IW, *IR = I1, *ou_t, uI;

	double IRf = 1; //! reward factor
	
	/* Start of simulations */
	// repeat for all training cycles
	for( int s = 0; s < TRAININGCYCLES; s++) {
	  // apply Bacon and Water stimulus alternatinglly with corresponding reward
		if( s%2==0 ) {
			ou_t = OU2; IB = I2; IW = I1; IRf = .5;
		} else {
			ou_t = OU1; IB = I1; IW = I2; IRf = 1; 
		}

		// now for all time bins:
		for( int t = 0; t < TIMEBINS; t++) {
			for( int i = 0; i < NPRE; i++) {
				mixOUs(ouP + i, ou_t[t * NPRE + i], MIX[t], oumP + i);
				updatePre(sueP+i, suiP+i, pspP + i, pspSP + i, pspTildeP + i, *(presP + i) = spiking(DT * phi(*(oumP + i)), gsl_ran_flat(r,0,1))); 
			}
			updateMembrane(&uB, &uVB, &uI, wB, psp, IB[t], 0);
			updateMembrane(&uW, &uVW, &uI, wW, psp, IW[t], 0);
			updateMembrane(&uR, &uVR, &uI, wR, psp, IRf*IR[t], 0);
			//rUB = spiking(phi(uB), gsl_ran_flat(r,0,1)); rVB = phi(uVB);
			//rUW = spiking(phi(uW), gsl_ran_flat(r,0,1)); rVW = phi(uVW);
			//rUR = spiking(phi(uR), gsl_ran_flat(r,0,1)); rVR = phi(uVR);

			//! do calculates on the potentials only, not the actual spikes:
			rUB = phi(uB); rVB = phi(uVB);
			rUW = phi(uW); rVW = phi(uVW);
			rUR = phi(uR); rVR = phi(uVR);

			for(int i = 0; i < NPRE; i++) {
				updateWeight(wBP + i, rUB, *(pspTildeP+i), rVB, *(pspSP+i));
				updateWeight(wWP + i, rUW, *(pspTildeP+i), rVW, *(pspSP+i));
				updateWeight(wRP + i, rUR, *(pspTildeP+i), rVR, *(pspSP+i));
			}

			// write out states after the first 10 cycles:
			if(s > TRAININGCYCLES - 9 ) { 
				for(int i=0; i<stateLength; i++) {
					fwrite(*(state+i), sizeof(double), 1, F);
				}
			}
		}
	}
	
	gsl_vector_free(psp); gsl_vector_free(pspS); gsl_vector_free(wB); gsl_vector_free(wW); gsl_vector_free(wR);
	free(ou); free(oum); free(OU1); free(OU2); free(MIX); free(I1); free(I2);
	
	fclose(F); 
	
	return 0;
}
Exemple #10
0
InventoryWindow::InventoryWindow(Inventory *const inventory) :
    Window("Inventory", Modal_false, nullptr, "inventory.xml"),
    ActionListener(),
    KeyListener(),
    SelectionListener(),
    InventoryListener(),
    AttributeListener(),
    mInventory(inventory),
    mItems(new ItemContainer(this, mInventory)),
    mUseButton(nullptr),
    mDropButton(nullptr),
    mOutfitButton(nullptr),
    mShopButton(nullptr),
    mCartButton(nullptr),
    mEquipmentButton(nullptr),
    mStoreButton(nullptr),
    mRetrieveButton(nullptr),
    mInvCloseButton(nullptr),
    mWeightBar(nullptr),
    mSlotsBar(new ProgressBar(this, 0.0F, 100, 0,
        ProgressColorId::PROG_INVY_SLOTS,
        "slotsprogressbar.xml", "slotsprogressbar_fill.xml")),
    mFilter(nullptr),
    mSortModel(new SortListModelInv),
    mSortDropDown(new DropDown(this, mSortModel, false,
        Modal_false, this, "sort")),
    mNameFilter(new TextField(this, "", true, this, "namefilter", true)),
    mSortDropDownCell(nullptr),
    mNameFilterCell(nullptr),
    mFilterCell(nullptr),
    mSlotsBarCell(nullptr),
    mSplit(false),
    mCompactMode(false)
{
    mSlotsBar->setColor(getThemeColor(ThemeColorId::SLOTS_BAR),
        getThemeColor(ThemeColorId::SLOTS_BAR_OUTLINE));

    if (inventory)
    {
        setCaption(gettext(inventory->getName().c_str()));
        setWindowName(inventory->getName());
        switch (inventory->getType())
        {
            case InventoryType::Inventory:
            case InventoryType::Trade:
            case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
            case InventoryType::Vending:
            case InventoryType::Mail:
            case InventoryType::Craft:
#endif
            case InventoryType::TypeEnd:
            default:
                mSortDropDown->setSelected(config.getIntValue(
                    "inventorySortOrder"));
                break;
            case InventoryType::Storage:
                mSortDropDown->setSelected(config.getIntValue(
                    "storageSortOrder"));
                break;
#ifdef EATHENA_SUPPORT
            case InventoryType::Cart:
                mSortDropDown->setSelected(config.getIntValue(
                    "cartSortOrder"));
                break;
#endif
        };
    }
    else
    {
        // TRANSLATORS: inventory window name
        setCaption(_("Inventory"));
        setWindowName("Inventory");
        mSortDropDown->setSelected(0);
    }

    if (setupWindow &&
        inventory &&
        inventory->getType() != InventoryType::Storage)
    {
        setupWindow->registerWindowForReset(this);
    }

    setResizable(true);
    setCloseButton(true);
    setSaveVisible(true);
    setStickyButtonLock(true);

    if (mainGraphics->mWidth > 600)
        setDefaultSize(450, 310, ImagePosition::CENTER);
    else
        setDefaultSize(387, 307, ImagePosition::CENTER);
    setMinWidth(310);
    setMinHeight(179);
    addKeyListener(this);

    mItems->addSelectionListener(this);

    ScrollArea *const invenScroll = new ScrollArea(this, mItems,
        getOptionBool("showbackground"), "inventory_background.xml");
    invenScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER);

    const int size = config.getIntValue("fontSize");
    mFilter = new TabStrip(this, "filter_" + getWindowName(), size + 16);
    mFilter->addActionListener(this);
    mFilter->setActionEventId("tag_");

    StringVect tags = ItemDB::getTags();
    const size_t sz = tags.size();
    for (size_t f = 0; f < sz; f ++)
        mFilter->addButton(tags[f], tags[f], false);

    if (!mInventory)
    {
        invInstances.push_back(this);
        return;
    }

    switch (mInventory->getType())
    {
        case InventoryType::Inventory:
        {
            // TRANSLATORS: inventory button
            const std::string equip = _("Equip");
            // TRANSLATORS: inventory button
            const std::string use = _("Use");
            // TRANSLATORS: inventory button
            const std::string unequip = _("Unequip");

            std::string longestUseString = getFont()->getWidth(equip) >
                getFont()->getWidth(use) ? equip : use;

            if (getFont()->getWidth(longestUseString) <
                getFont()->getWidth(unequip))
            {
                longestUseString = unequip;
            }

            mUseButton = new Button(this, longestUseString, "use", this);
            // TRANSLATORS: inventory button
            mDropButton = new Button(this, _("Drop..."), "drop", this);
            // TRANSLATORS: inventory outfits button
            mOutfitButton = new Button(this, _("O"), "outfit", this);
            // TRANSLATORS: inventory cart button
            mCartButton = new Button(this, _("C"), "cart", this);
            // TRANSLATORS: inventory shop button
            mShopButton = new Button(this, _("S"), "shop", this);
            // TRANSLATORS: inventory equipment button
            mEquipmentButton = new Button(this, _("E"), "equipment", this);
            mWeightBar = new ProgressBar(this, 0.0F, 100, 0,
                ProgressColorId::PROG_WEIGHT,
                "weightprogressbar.xml", "weightprogressbar_fill.xml");
            mWeightBar->setColor(getThemeColor(ThemeColorId::WEIGHT_BAR),
                getThemeColor(ThemeColorId::WEIGHT_BAR_OUTLINE));

            // TRANSLATORS: outfits button tooltip
            mOutfitButton->setDescription(_("Outfits"));
            // TRANSLATORS: cart button tooltip
            mCartButton->setDescription(_("Cart"));
            // TRANSLATORS: shop button tooltip
            mShopButton->setDescription(_("Shop"));
            // TRANSLATORS: equipment button tooltip
            mEquipmentButton->setDescription(_("Equipment"));

            place(0, 0, mWeightBar, 4);
            mSlotsBarCell = &place(4, 0, mSlotsBar, 4);
            mSortDropDownCell = &place(8, 0, mSortDropDown, 3);

            mFilterCell = &place(0, 1, mFilter, 10).setPadding(3);
            mNameFilterCell = &place(8, 1, mNameFilter, 3);

            place(0, 2, invenScroll, 11).setPadding(3);
            place(0, 3, mUseButton);
            place(1, 3, mDropButton);
            ContainerPlacer placer = getPlacer(10, 3);
            placer(0, 0, mShopButton);
            placer(1, 0, mOutfitButton);
            placer(2, 0, mCartButton);
            placer(3, 0, mEquipmentButton);

            updateWeight();
            break;
        }

        case InventoryType::Storage:
        {
            // TRANSLATORS: storage button
            mStoreButton = new Button(this, _("Store"), "store", this);
            // TRANSLATORS: storage button
            mRetrieveButton = new Button(this, _("Retrieve"),
                "retrieve", this);
            // TRANSLATORS: storage button
            mInvCloseButton = new Button(this, _("Close"), "close", this);

            mSlotsBarCell = &place(0, 0, mSlotsBar, 6);
            mSortDropDownCell = &place(6, 0, mSortDropDown, 1);

            mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
            mNameFilterCell = &place(6, 1, mNameFilter, 1);

            place(0, 2, invenScroll, 7, 4);
            place(0, 6, mStoreButton);
            place(1, 6, mRetrieveButton);
            place(6, 6, mInvCloseButton);
            break;
        }

#ifdef EATHENA_SUPPORT
        case InventoryType::Cart:
        {
            // TRANSLATORS: storage button
            mStoreButton = new Button(this, _("Store"), "store", this);
            // TRANSLATORS: storage button
            mRetrieveButton = new Button(this, _("Retrieve"),
                "retrieve", this);
            // TRANSLATORS: storage button
            mInvCloseButton = new Button(this, _("Close"), "close", this);

            mWeightBar = new ProgressBar(this, 0.0F, 100, 0,
                ProgressColorId::PROG_WEIGHT,
                "weightprogressbar.xml", "weightprogressbar_fill.xml");
            mWeightBar->setColor(getThemeColor(ThemeColorId::WEIGHT_BAR),
                getThemeColor(ThemeColorId::WEIGHT_BAR_OUTLINE));

            mSlotsBarCell = &place(3, 0, mSlotsBar, 3);
            mSortDropDownCell = &place(6, 0, mSortDropDown, 1);

            mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
            mNameFilterCell = &place(6, 1, mNameFilter, 1);

            place(0, 0, mWeightBar, 3);
            place(0, 2, invenScroll, 7, 4);
            place(0, 6, mStoreButton);
            place(1, 6, mRetrieveButton);
            place(6, 6, mInvCloseButton);
            break;
        }
#endif

        default:
        case InventoryType::Trade:
        case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
        case InventoryType::Vending:
        case InventoryType::Mail:
        case InventoryType::Craft:
#endif
        case InventoryType::TypeEnd:
            break;
    };

    Layout &layout = getLayout();
    layout.setRowHeight(2, LayoutType::SET);

    mInventory->addInventoyListener(this);

    invInstances.push_back(this);

    if (inventory->isMainInventory())
    {
        updateDropButton();
    }
    else
    {
        if (!invInstances.empty())
            invInstances.front()->updateDropButton();
    }

    loadWindowState();
    enableVisibleSound(true);
}
void MultiplicativeWeightsLearningModel::updateWeights(std::vector<Value> profits, Value, double phi) {

    struct StratUsage {
        Value profits;
        MinerCount minersUsing;
        
        StratUsage() : profits(0), minersUsing(0) {}
        
        void addProfit(Value profit) {
            profits += profit;
            minersUsing++;
        }
        
        void normalize() {
            if (minersUsing > MinerCount(1)) {
                profits /= Value(minersUsing);
                minersUsing = MinerCount(1);
            }
        }
        
        bool isUnused() {
            return minersUsing == MinerCount(0);
        }
        
        double profitRatio(Value maxProfits) {
            assert(profits <= maxProfits);
            return rawValue(profits/maxProfits);
        }
    };
    
    std::vector<StratUsage> stratUsages;
    stratUsages.resize(stratCount);
    
    for (size_t i = 0; i < minerCount; i++) {
        stratUsages[getChosenStrat(i)].addProfit(profits[i]);
    }
    
    Value maxProfits(0);
    for (auto &stratUsage : stratUsages) {
        stratUsage.normalize();
        if (maxProfits < stratUsage.profits) {
            maxProfits = stratUsage.profits;
        }
    }
    
    std::vector<StratWeight> newWeights;
    newWeights.reserve(stratCount);
    
    StratWeight totalWeight(0);
    for (size_t i = 0; i < stratUsages.size(); i++) {
        double c_t = 1.1 - stratUsages[i].profitRatio(maxProfits);
        if (stratUsages[i].isUnused()) {
            //means no one tried the strategy, keep weight unchanged (encourage exploration)?
            c_t = 0;
        }
        
        StratWeight newWeight = getCurrentWeight(i) * StratWeight(pow((1-phi), c_t));
        updateWeight(i, newWeight);
        totalWeight += newWeight;
        newWeights.push_back(newWeight);
    }
    
    for (size_t i = 0; i < newWeights.size(); i++) {
        updateWeight(i, newWeights[i] / totalWeight);
    }
    
    std::vector<StratWeight> weights = getCurrentWeights();
    
    probabilities.clear();
    probabilities.reserve(stratCount);
    std::transform(begin(weights), end(weights), std::back_inserter(probabilities), [](const auto &weight) { return rawWeight(weight); });
}
Exemple #12
0
InventoryWindow::InventoryWindow(Inventory *const inventory):
    Window("Inventory", false, nullptr, "inventory.xml"),
    gcn::ActionListener(),
    gcn::KeyListener(),
    gcn::SelectionListener(),
    InventoryListener(),
    mInventory(inventory),
    mItems(new ItemContainer(this, mInventory)),
    mWeight(),
    mSlots(),
    mUseButton(nullptr),
    mDropButton(nullptr),
    mSplitButton(nullptr),
    mOutfitButton(nullptr),
    mShopButton(nullptr),
    mEquipmentButton(nullptr),
    mStoreButton(nullptr),
    mRetrieveButton(nullptr),
    mInvCloseButton(nullptr),
    mWeightBar(nullptr),
    mSlotsBar(new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_INVY_SLOTS)),
    mFilter(nullptr),
    mSortModel(new SortListModelInv),
    mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")),
    mNameFilter(new TextField(this, "", true, this, "namefilter", true)),
    mSortDropDownCell(nullptr),
    mNameFilterCell(nullptr),
    mFilterCell(nullptr),
    mSlotsBarCell(nullptr),
    mSplit(false),
    mCompactMode(false)
{
    if (inventory)
    {
        setCaption(gettext(inventory->getName().c_str()));
        setWindowName(inventory->getName());
    }
    else
    {
        // TRANSLATORS: inventory window name
        setCaption(_("Inventory"));
        setWindowName("Inventory");
    }

    listen(CHANNEL_ATTRIBUTES);

    if (setupWindow)
        setupWindow->registerWindowForReset(this);

    setResizable(true);
    setCloseButton(true);
    setSaveVisible(true);
    setStickyButtonLock(true);

    setDefaultSize(387, 307, ImageRect::CENTER);
    setMinWidth(310);
    setMinHeight(179);
    addKeyListener(this);

    mItems->addSelectionListener(this);

    gcn::ScrollArea *const invenScroll = new ScrollArea(
        mItems, getOptionBool("showbackground"), "inventory_background.xml");
    invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);

    const int size = config.getIntValue("fontSize");
    mFilter = new TabStrip(this, "filter_" + getWindowName(), size + 16);
    mFilter->addActionListener(this);
    mFilter->setActionEventId("tag_");

    mSortDropDown->setSelected(0);

    StringVect tags = ItemDB::getTags();
    for (unsigned f = 0; f < tags.size(); f ++)
        mFilter->addButton(tags[f]);

    if (isMainInventory())
    {
        // TRANSLATORS: inventory button
        const std::string equip = _("Equip");
        // TRANSLATORS: inventory button
        const std::string use = _("Use");
        // TRANSLATORS: inventory button
        const std::string unequip = _("Unequip");

        std::string longestUseString = getFont()->getWidth(equip) >
            getFont()->getWidth(use) ? equip : use;

        if (getFont()->getWidth(longestUseString) <
            getFont()->getWidth(unequip))
        {
            longestUseString = unequip;
        }

        mUseButton = new Button(this, longestUseString, "use", this);
        // TRANSLATORS: inventory button
        mDropButton = new Button(this, _("Drop..."), "drop", this);
        // TRANSLATORS: inventory button
        mSplitButton = new Button(this, _("Split"), "split", this);
        // TRANSLATORS: inventory button
        mOutfitButton = new Button(this, _("Outfits"), "outfit", this);
        // TRANSLATORS: inventory button
        mShopButton = new Button(this, _("Shop"), "shop", this);
        // TRANSLATORS: inventory button
        mEquipmentButton = new Button(this, _("Equipment"), "equipment", this);
        mWeightBar = new ProgressBar(this, 0.0f, 100, 0, Theme::PROG_WEIGHT);

        place(0, 0, mWeightBar, 4);
        mSlotsBarCell = &place(4, 0, mSlotsBar, 5);
        mSortDropDownCell = &place(9, 0, mSortDropDown, 2);

        mFilterCell = &place(0, 1, mFilter, 10).setPadding(3);
        mNameFilterCell = &place(9, 1, mNameFilter, 2);

        place(0, 2, invenScroll, 11).setPadding(3);
        place(0, 3, mUseButton);
        place(1, 3, mDropButton);
        place(8, 2, mSplitButton);
        place(8, 3, mShopButton);
        place(9, 3, mOutfitButton);
        place(10, 3, mEquipmentButton);

        updateWeight();
    }
    else
    {
        // TRANSLATORS: storage button
        mStoreButton = new Button(this, _("Store"), "store", this);
        // TRANSLATORS: storage button
        mRetrieveButton = new Button(this, _("Retrieve"), "retrieve", this);
        // TRANSLATORS: storage button
        mInvCloseButton = new Button(this, _("Close"), "close", this);

        mSlotsBarCell = &place(0, 0, mSlotsBar, 6);
        mSortDropDownCell = &place(6, 0, mSortDropDown, 1);

        mFilterCell = &place(0, 1, mFilter, 7).setPadding(3);
        mNameFilterCell = &place(6, 1, mNameFilter, 1);

        place(0, 2, invenScroll, 7, 4);
        place(0, 6, mStoreButton);
        place(1, 6, mRetrieveButton);
        place(6, 6, mInvCloseButton);
    }

    Layout &layout = getLayout();
    layout.setRowHeight(2, Layout::AUTO_SET);

    mInventory->addInventoyListener(this);

    invInstances.push_back(this);

    if (inventory && inventory->isMainInventory())
    {
        updateDropButton();
    }
    else
    {
        if (!invInstances.empty())
            invInstances.front()->updateDropButton();
    }

    loadWindowState();
    enableVisibleSound(true);
    slotsChanged(mInventory);

    widgetResized(gcn::Event(nullptr));
    if (!isMainInventory())
        setVisible(true);
}
Exemple #13
0
ompl::base::PlannerStatus ompl::control::LTLPlanner::solve(const ompl::base::PlannerTerminationCondition &ptc)
{
    // \todo make solve work when called more than once!
    checkValidity();
    const base::State *start = pis_.nextStart();
    prodStart_ = ltlsi_->getProdGraphState(start);

    if (pis_.haveMoreStartStates())
        OMPL_WARN("Multiple start states given. Using only the first start state.");

    auto *startMotion = new Motion(ltlsi_);
    si_->copyState(startMotion->state, start);
    ltlsi_->nullControl(startMotion->control);
    startMotion->abstractState = prodStart_;

    motions_.push_back(startMotion);
    abstractInfo_[prodStart_].addMotion(startMotion);
    updateWeight(prodStart_);
    availDist_.add(prodStart_, abstractInfo_[prodStart_].weight);

    abstraction_->buildGraph(prodStart_, [this](ProductGraph::State *as)
                             {
                                 initAbstractInfo(as);
                             });

    if (!sampler_)
        sampler_ = si_->allocStateSampler();
    if (!controlSampler_)
        controlSampler_ = ltlsi_->allocControlSampler();

    bool solved = false;
    Motion *soln;

    while (ptc() == false && !solved)
    {
        const std::vector<ProductGraph::State *> lead =
            abstraction_->computeLead(prodStart_, [this](ProductGraph::State *a, ProductGraph::State *b)
                                      {
                                          return abstractEdgeWeight(a, b);
                                      });
        buildAvail(lead);
        solved = explore(lead, soln, exploreTime_);
    }

    if (solved)
    {
        // build solution path
        std::vector<Motion *> path;
        while (soln != nullptr)
        {
            path.push_back(soln);
            soln = soln->parent;
        }
        auto pc(std::make_shared<PathControl>(si_));
        for (int i = path.size() - 1; i >= 0; --i)
        {
            if (path[i]->parent != nullptr)
                pc->append(path[i]->state, path[i]->control, path[i]->steps * ltlsi_->getPropagationStepSize());
            else
                pc->append(path[i]->state);
        }
        pdef_->addSolutionPath(pc);
    }

    OMPL_INFORM("Created %u states", motions_.size());
    return {solved, false};
}
Exemple #14
0
void OrdinalTree<T, M>::rotateRight(Node* k1)
{
	Super::rotateRight(k1);
	updateWeight(k1);
	updateWeight(k1->parent);
}
Exemple #15
0
InventoryWindow::InventoryWindow(Inventory *inventory):
    Window(inventory->isMainInventory() ? _("Inventory") : _("Storage")),
    mInventory(inventory),
    mSplit(false)
{
    listen("Attributes");

    setWindowName(isMainInventory() ? "Inventory" : "Storage");
    setupWindow->registerWindowForReset(this);
    setResizable(true);
    setCloseButton(true);
    setSaveVisible(true);

    setDefaultSize(387, 307, ImageRect::CENTER);
    setMinWidth(316);
    setMinHeight(179);
    addKeyListener(this);

    mItems = new ItemContainer(mInventory);
    mItems->addSelectionListener(this);

    gcn::ScrollArea *invenScroll = new ScrollArea(mItems);
    invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);

    mSlotsLabel = new Label(_("Slots:"));
    mSlotsBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_INVY_SLOTS);

    if (isMainInventory())
    {
        std::string equip = _("Equip");
        std::string use = _("Use");
        std::string unequip = _("Unequip");

        std::string longestUseString = getFont()->getWidth(equip) >
                                       getFont()->getWidth(use) ? equip : use;

        if (getFont()->getWidth(longestUseString) <
            getFont()->getWidth(unequip))
        {
            longestUseString = unequip;
        }

        mUseButton = new Button(longestUseString, "use", this);
        mDropButton = new Button(_("Drop..."), "drop", this);
        mSplitButton = new Button(_("Split"), "split", this);
        mOutfitButton = new Button(_("Outfits"), "outfit", this);

        mWeightLabel = new Label(_("Weight:"));
        mWeightBar = new ProgressBar(0.0f, 100, 20, Theme::PROG_WEIGHT);

        place(0, 0, mWeightLabel).setPadding(3);
        place(1, 0, mWeightBar, 3);
        place(4, 0, mSlotsLabel).setPadding(3);
        place(5, 0, mSlotsBar, 2);
        place(0, 1, invenScroll, 7).setPadding(3);
        place(0, 2, mUseButton);
        place(1, 2, mDropButton);
        place(2, 2, mSplitButton);
        place(6, 2, mOutfitButton);

        updateWeight();
    }
    else
    {
        mStoreButton = new Button(_("Store"), "store", this);
        mRetrieveButton = new Button(_("Retrieve"), "retrieve", this);

        place(0, 0, mSlotsLabel).setPadding(3);
        place(1, 0, mSlotsBar, 3);
        place(0, 1, invenScroll, 4, 4);
        place(0, 5, mStoreButton);
        place(1, 5, mRetrieveButton);
    }

    Layout &layout = getLayout();
    layout.setRowHeight(1, Layout::AUTO_SET);

    mInventory->addInventoyListener(this);

    instances.push_back(this);

    loadWindowState();
    slotsChanged(mInventory);

    if (!isMainInventory())
    {
        setVisible(true);
        PlayerInfo::setStorageCount(PlayerInfo::getStorageCount() + 1);
    }
}
Exemple #16
0
/**
 main simulation loop
*/
int main() {

  // init own parameters.
  initDerivedParams(); 

  // init random generator
  gsl_rng_env_setup();
  r = gsl_rng_alloc(gsl_rng_default);
  gsl_rng_set(r, SEED_MAIN);

  // file handle for xxx file
  FILE *postF = fopen(FILENAME_POST, FILEPOST_FLAG);

  // file handle for xxx file
  FILE *preF = fopen(FILENAME_PRE, "wb");
	
  // set up vectors:

  // to hold post synaptic potentials [unused??]
  gsl_vector *psp = gsl_vector_alloc(NPRE);
  // to hold post synaptic potentials 1st filtered
  gsl_vector *pspS = gsl_vector_alloc(NPRE);
  // to hold "excitatory" part of psp for Euler integration
  gsl_vector *sue = gsl_vector_alloc(NPRE);
  // to hold "inhibitory" part of psp for Euler integration
  gsl_vector *sui = gsl_vector_alloc(NPRE);
  // to hold psp 2nd filter
  gsl_vector *pspTilde = gsl_vector_alloc(NPRE);
  // to hold weights
  gsl_vector *w  = gsl_vector_alloc(NPRE);
  // to hold xxx
  gsl_vector *pres  = gsl_vector_alloc(NPRE);

  // ?? ou XXX \todo
#ifdef PREDICT_OU
  gsl_vector *ou = gsl_vector_alloc(N_OU);
  gsl_vector *preU = gsl_vector_calloc(NPRE);
  gsl_vector *wInput = gsl_vector_alloc(N_OU);
  gsl_matrix *wPre  = gsl_matrix_calloc(NPRE, N_OU);
  double *preUP = gsl_vector_ptr(preU,0);
  double *ouP = gsl_vector_ptr(ou,0);
  double *wInputP = gsl_vector_ptr(wInput,0);
  double *wPreP = gsl_matrix_ptr(wPre,0,0);
#endif

  // get pointers to array within the gsl_vector data structures above.
  double *pspP = gsl_vector_ptr(psp,0);
  double *pspSP = gsl_vector_ptr(pspS,0);
  double *sueP = gsl_vector_ptr(sue,0);
  double *suiP = gsl_vector_ptr(sui,0);
  double *pspTildeP = gsl_vector_ptr(pspTilde,0);
  double *wP = gsl_vector_ptr(w,0);
  double *presP = gsl_vector_ptr(pres,0);

  for(int i=0; i<NPRE; i++) {

    // init pspP etc to zero
    *(pspP+i) = 0;
    *(sueP+i) = 0;
    *(suiP+i) = 0;
#ifdef RANDI_WEIGHTS
    // Gaussian weights
    *(wP+i) = gsl_ran_gaussian(r, .1);
#else
    *(wP+i) = 0;
#endif
  }


  //! OU \todo what for?	
#ifdef PREDICT_OU
  for(int j=0; j < N_OU; j++) {
    *(ouP + j) = gsl_ran_gaussian(r, 1) + M_OU;
    *(wInputP + j) = gsl_ran_lognormal(r, 0., 2.)/N_OU/exp(2.)/2.;
    for(int i=0; i < NPRE; i++) *(wPreP + j*NPRE + i) = gsl_ran_lognormal(r, 0., 2.)/N_OU/exp(2.)/2.;
  }
#endif

  // temp variables for the simulation yyyy
  double 
    u = 0, // soma potential.
    uV = 0, // some potential from dendrite only (ie discounted
	    // dendrite potential
    rU = 0, // instantneou rate 
    rV = 0, // rate on dendritic potential only
    uI = 0, // soma potential only from somatic inputs
    rI = 0, // rate on somatic potential only
    uInput = 0; // for OU?

  // run simulatio TRAININGCYCLES number of times
  for( int s = 0; s < TRAININGCYCLES; s++) {

    // for all TIMEBINS
    for( int t = 0; t < TIMEBINS; t++) {

#ifdef PREDICT_OU
      for(int i = 0; i < N_OU; i++) {
	*(ouP+i) = runOU(*(ouP+i), M_OU, GAMMA_OU, S_OU);
      }
      gsl_blas_dgemv(CblasNoTrans, 1., wPre, ou, 0., preU); 
#endif

      // update PSP of our neurons for inputs from all presynaptic neurons
      for( int i = 0; i < NPRE; i++) {

#ifdef RAMPUPRATE
	/** just read in the PRE_ACT and generate a spike and store it in presP -- so PRE_ACT has inpretation of potential */
	updatePre(sueP+i, suiP+i, pspP + i, pspSP + i, pspTildeP + i, *(presP + i) = spiking(PRE_ACT[t*NPRE + i], gsl_rng_uniform(r)));

#elif defined PREDICT_OU
	//*(ouP+i) = runOU(*(ouP+i), M_OU, GAMMA_OU, S_OU); // why commented out?
	updatePre(sueP+i, suiP+i, pspP + i, pspSP + i, pspTildeP + i, *(presP + i) = DT * phi(*(preUP+i)));//spiking(DT * phi(*(preUP+i)), gsl_rng_uniform(r))); // why commented out?

#else
	// PRE_ACT intepreated as spikes
	updatePre(sueP+i, suiP+i, pspP + i, pspSP + i, pspTildeP + i, *(presP + i) = PRE_ACT[t*NPRE + i]);
#endif
      } // endfor NPRE

#ifdef PREDICT_OU
      gsl_blas_ddot(wInput, ou, &uInput);
      GE[t] = DT * phi(uInput);

#endif
      // now update the membrane potential.
      updateMembrane(&u, &uV, &uI, w, psp, GE[t], GI[t]);


      // now calculate rates from from potentials.
#ifdef POSTSPIKING // usually switch off as learning is faster when
		   // learning from U
      // with low-pass filtering of soma potential from actual
      // generation of spikes (back propgating dentric spikes?
      rU = GAMMA_POSTS*rU + (1-GAMMA_POSTS)*spiking(DT * phi(u),  gsl_rng_uniform(r))/DT;
#else
      // simpler -- direct.
      rU = phi(u); 
#endif
      rV = phi(uV); rI = phi(uI);

      // now update weights based on rU, RV, the 2nd filtered PSP and
      // the pspSP
      for(int i = 0; i < NPRE; i++) {
	updateWeight(wP + i, rU, *(pspTildeP+i), rV, *(pspSP+i));
      }
#ifdef TAUEFF
      /**
	 write rU to postF, but only for the last run of the
	 simulation and then only before the STIM_ONSET time --
	 ie it is the trained output without somatic drive.
       */
      if(s == TRAININGCYCLES - 1 && t < STIM_ONSET/DT) {
	fwrite(&rU, sizeof(double), 1, postF); 
      }
#else
      /**
	 for every 10th training cycle write all variables below to
	 postF in order:
       */
      if(s%(TRAININGCYCLES/10)==0) {
	fwrite(&rU, sizeof(double), 1, postF);
	fwrite(GE+t, sizeof(double), 1, postF);
	fwrite(&rV, sizeof(double), 1, postF);
	fwrite(&rI, sizeof(double), 1, postF);
	fwrite(&u, sizeof(double), 1, postF);
      }
      if(s == TRAININGCYCLES - 1) {
#ifdef RECORD_PREACT
	// for the last cycle also record the activity of the
	// presynaptic neurons
	fwrite(PRE_ACT + t * NPRE, sizeof(double), 20, preF);
	//fwrite(ouP, sizeof(double), 20, preF);
	fwrite(presP, sizeof(double), 20, preF);
#else
	// and the 1st and 2nd filtered PSP
	fwrite(pspSP, sizeof(double), 1, preF);
	fwrite(pspTildeP, sizeof(double), 1, preF);
#endif
      }
#endif
    }
  }
  
  fclose(preF);
  fclose(postF);
  
  return 0;
}
Exemple #17
0
bool ompl::control::LTLPlanner::explore(const std::vector<ProductGraph::State *> &lead, Motion *&soln, double duration)
{
    bool solved = false;
    base::PlannerTerminationCondition ptc = base::timedPlannerTerminationCondition(duration);
    base::GoalPtr goal = pdef_->getGoal();
    while (!ptc() && !solved)
    {
        ProductGraph::State *as = availDist_.sample(rng_.uniform01());
        ++abstractInfo_[as].numSel;
        updateWeight(as);

        PDF<Motion *> &motions = abstractInfo_[as].motions;
        Motion *v = motions.sample(rng_.uniform01());
        PDF<Motion *>::Element *velem = abstractInfo_[as].motionElems[v];
        double vweight = motions.getWeight(velem);
        if (vweight > 1e-20)
            motions.update(velem, vweight / (vweight + 1.));

        Control *rctrl = ltlsi_->allocControl();
        controlSampler_->sampleNext(rctrl, v->control, v->state);
        unsigned int cd =
            controlSampler_->sampleStepCount(ltlsi_->getMinControlDuration(), ltlsi_->getMaxControlDuration());

        base::State *newState = si_->allocState();
        cd = ltlsi_->propagateWhileValid(v->state, rctrl, cd, newState);
        if (cd < ltlsi_->getMinControlDuration())
        {
            si_->freeState(newState);
            ltlsi_->freeControl(rctrl);
            continue;
        }
        auto *m = new Motion();
        m->state = newState;
        m->control = rctrl;
        m->steps = cd;
        m->parent = v;
        // Since the state was determined to be valid by SpaceInformation, we don't need to check automaton states
        m->abstractState = ltlsi_->getProdGraphState(m->state);
        motions_.push_back(m);

        abstractInfo_[m->abstractState].addMotion(m);
        updateWeight(m->abstractState);
        // update weight if hl state already exists in avail
        if (abstractInfo_[m->abstractState].pdfElem != nullptr)
            availDist_.update(abstractInfo_[m->abstractState].pdfElem, abstractInfo_[m->abstractState].weight);
        else
        {
            // otherwise, only add hl state to avail if it already exists in lead
            if (std::find(lead.begin(), lead.end(), m->abstractState) != lead.end())
            {
                PDF<ProductGraph::State *>::Element *elem =
                    availDist_.add(m->abstractState, abstractInfo_[m->abstractState].weight);
                abstractInfo_[m->abstractState].pdfElem = elem;
            }
        }

        solved = goal->isSatisfied(m->state);
        if (solved)
        {
            soln = m;
            break;
        }
    }
    return solved;
}
Exemple #18
0
int main() {
	gsl_rng_env_setup();
	r = gsl_rng_alloc(gsl_rng_default);
	gsl_rng_set(r, RANDOM_SEED);
	initDerivedParams();
	
	FILE *outF = fopen("data/recurrent.dat", "w+b");
	FILE *wDF = fopen("data/recurrentWD.dat", "w+b");
	FILE *wF = fopen("data/recurrentW.dat", "w+b");
	
	gsl_rng_set(r, 0);
	
	gsl_vector *psp = gsl_vector_calloc(N);
	gsl_vector *pspS = gsl_vector_calloc(N);
	gsl_vector *sue = gsl_vector_calloc(N);
	gsl_vector *sui = gsl_vector_calloc(N);
	gsl_vector *pspTilde = gsl_vector_calloc(N);
	gsl_matrix *w  = gsl_matrix_calloc(N, N);
	gsl_vector *u  = gsl_vector_calloc(N);
	gsl_vector *uV  = gsl_vector_calloc(N);
	gsl_vector *pre  = gsl_vector_calloc(N);
	gsl_vector *rU  = gsl_vector_calloc(N);
	gsl_vector *rV  = gsl_vector_calloc(N);
	double *pspP = gsl_vector_ptr(psp,0);
	double *pspSP = gsl_vector_ptr(pspS,0);
	double *sueP = gsl_vector_ptr(sue,0);
	double *suiP = gsl_vector_ptr(sui,0);
	double *pspTildeP = gsl_vector_ptr(pspTilde,0);
	double *wP = gsl_matrix_ptr(w,0,0);
	double *uP = gsl_vector_ptr(u,0);
	double *uVP = gsl_vector_ptr(uV,0);
	double *preP = gsl_vector_ptr(pre,0);
	double *rUP = gsl_vector_ptr(rU,0);
	double *rVP = gsl_vector_ptr(rV,0);

	
	int stateLength = 2 * N ;
	double *state[stateLength];
	for(int i = 0; i < N; i++) {
		*(state + 0*N + i) = preP + i;
		*(state + 1*N + i) = rUP + i;
	} 
	
	gsl_vector_view tmpv; double gE, wij, wd, uI;

	for( int s = 0; s < TRAININGCYCLES+5; s++) {
		wd = 0;
		for( int t = 0; t < TIMEBINS; t++) {
			for( int i = 0; i < N; i++) {
				updatePre(sueP+i, suiP+i, pspP + i, pspSP + i, pspTildeP + i, *(preP + i) = spiking(*(rUP+i), gsl_rng_uniform_pos(r))); 
				tmpv = gsl_matrix_row(w, i);
				if(s < TRAININGCYCLES - 1) gE = *(GE + t*N + i);
				else if(t < 1*TIMEBINS/8 && s == TRAININGCYCLES + 3) gE = *(GE + i); 
				//&& t < 2*TIMEBINS/3 + TIMEBINS/NGROUPS/5
				else gE = 0;
				updateMembrane(uP+i, uVP+i, &uI, &tmpv.vector, psp, gE, 0);
				*(rUP+i) = phi(*(uP+i)); *(rVP+i) = phi(*(uVP+i));
				for(int j = 0; j < N; j++) {
					wij = *(wP + i*N + j);
					if(i != j) {
						updateWeight(wP + i*N + j, *(rUP+i), *(pspTildeP+j), *(rVP+i), *(pspSP+j));
						wd += (wij -  *(wP + i*N + j)) * (wij -  *(wP + i*N + j));
					}
					if( s == TRAININGCYCLES - 1 && t == TIMEBINS - 1) fwrite(&wij, sizeof(double), 1, wF);
				}
			}
			if(s > TRAININGCYCLES - 4) {
				for(int i=0; i<stateLength; i++) fwrite(*(state+i), sizeof(double), 1, outF);
			}
		}
		fwrite(&wd, sizeof(double), 1, wDF);
	}

	fclose(outF); 
	fclose(wDF); 
	fclose(wF); 
	
	return 0;
}