This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Routine for real variable SBX crossover taken from the author's implementation (Kalyanmoy Deb). | |
* | |
* Paper describing the algorithm: | |
* Title: An Efficient Constraint Handling Method for Genetic Algorithms | |
* Author: Kalyanmoy Deb | |
* More info: Appendix A. Page 30. | |
* URL: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.33.7291&rep=rep1&type=pdf | |
* | |
* Commentaries by Tiago Peres França. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Routine for real variable SBX crossover based on the original implementation by Kalyanmoy Deb. | |
* The following implementation is written in Javascript using functional programming, in my | |
* opinion, it's easier to understand than the original C version (procedural). | |
* | |
* Implementation by Tiago Peres França | |
* | |
* OBS1: Based on the following code and paper: https://gist.github.com/Tiagoperes/1779d5f1c89bae0cfdb87b1960bba36d | |
* | |
* OBS2: functions starting by "_." are from the functional library Lodash. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROCESSO PRINCIPAL: | |
------------------------------------------------------------------------------------ | |
populacao = gera_populacao; | |
matriz_distancias = calcular_matriz_distancias(populacao, objetivos); | |
calcular_fitness(populacao, objetivos, matriz_distancias); | |
arquivo = selecionar_arquivo(populacao, tam_arquivo); | |
for (i = 0; i < numero_geracoes; i++) { | |
pais = selecionar_pais(arquivo, tam_populacao); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
const api = axios.create({ | |
mode: 'cors', | |
baseURL: 'http://localhost:3000', | |
}) | |
// if we don't write the next line, our resources will receive the entire response in the data field. We don't want that. | |
api.interceptors.response.use(response => response.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import createResource from '@zup-next/redux-resource' | |
import api from '../api' | |
const profile = createResource('PROFILE', { | |
load: api.loadProfile, | |
update: api.saveProfile, | |
}) | |
const catalog = createResource('CATALOG', { load: api.loadCatalog }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createStore, applyMiddleware, combineReducers } from 'redux' | |
import createSagaMiddleware from 'redux-saga' | |
import resources from './resources' | |
import { createEffects } from '@zup-next/redux-resource' | |
const reducers = combineReducers({ | |
catalog: resources.catalog.reducers, | |
order: resources.order.reducers, | |
profile: resources.profile.reducers, | |
wallet: resources.wallet.reducers, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PureComponent } from 'react' | |
import { connect } from 'react-redux' | |
import resources from '../../store/resources' | |
import { HeaderBar, HeaderContent, Top, Bottom } from './styled' | |
import { isPristine, isLoading, hasLoadError } from '@zup-next/redux-resource' | |
const Loading = () => <HeaderBar><HeaderContent>Loading...</HeaderContent></HeaderBar> | |
const Error = () => <HeaderBar><HeaderContent>Error!</HeaderContent></HeaderBar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (profile.load.status === 'pristine') || wallet.load.status === 'pristine') return null | |
if (profile.load.status === 'pending') || wallet.load.status === 'pending') return <Loading /> | |
if (profile.load.status === 'error') || wallet.load.status === 'error') return <Error /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Home extends PureComponent { | |
componentDidMount() { | |
const { loadCatalog } = this.props | |
loadCatalog() | |
} | |
render() { | |
const { catalog } = this.props |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const findMovieById = (catalog, id) => find(catalog.data, { id: parseInt(id) }) | |
class Movie extends PureComponent { | |
componentDidMount() { | |
const { loadCatalog } = this.props | |
loadCatalog() | |
} | |
render() { |
OlderNewer